jatar_k

msg:4544788 | 3:04 am on Feb 12, 2013 (gmt 0) |
well you could look at 2 things, one being using IN [dev.mysql.com] for the multiple values for category1 and also you can use various forms of ORDER BY [dev.mysql.com]
|
actolearn

msg:4544816 | 5:20 am on Feb 12, 2013 (gmt 0) |
Thank you for the links. After looking at 2 pages worth of code, I really couldn't tell what might apply. I didn't understand most of it. I've simplified what I need help with as shown below. Would appreciate someone showing me how to combine those two WHERE clauses. Thank you. SELECT * FROM tablename WHERE status='current' ORDER BY prod_number DESC WHERE status='sold' ORDER BY date_of_sale DESC
|
jatar_k

msg:4545159 | 3:31 am on Feb 13, 2013 (gmt 0) |
I think you can put them together I am just not 100% sure it would make sense easy enough to grab the 2 values for status where status in ('current', 'sold') you can then add an order by with the two column listed in order ORDER BY prod_number DESC, date_of_sale DESC I am not sure that will look like you think, maybe add a third order by for status or a group by, hard to be absolutely sure with out knowing exactly what the data is one option that might actually make more sense is to issue the 2 queries individually and then load each into a php array and display them how you like.
|
actolearn

msg:4545372 | 4:48 pm on Feb 13, 2013 (gmt 0) |
Thank you for your response and I see what you mean. I'm not getting exactly what I want but at least I now have both the active and sold showing in my gallery. I didn't know to do this: WHERE status in ('active', 'sold') I used status= but got incorrect results because of my other conditions so "status in..." really helped. I'll research more re third "order by" and "grouping". Thx again ~
|
jatar_k

msg:4545379 | 5:00 pm on Feb 13, 2013 (gmt 0) |
SELECT * FROM tablename WHERE status in ('active', 'sold') ORDER BY prod_number DESC, date_of_sale DESC should work just like that
|
actolearn

msg:4545395 | 5:22 pm on Feb 13, 2013 (gmt 0) |
Yes, it works but sold is mixed in with the active items instead of in a group by itself at bottom of gallery. Group 1 = active = order by prod_number DESC Group 2 = sold = order by date_of_sale DESC ..... and GROUP together below the active group. Is what I want not possible? Thx - AC
|
jatar_k

msg:4545566 | 5:45 am on Feb 14, 2013 (gmt 0) |
I guess you could add status to the order SELECT * FROM tablename WHERE status in ('active', 'sold') ORDER BY status desc, prod_number DESC, date_of_sale DESC
|
actolearn

msg:4545706 | 7:28 pm on Feb 14, 2013 (gmt 0) |
| ORDER BY status DESC, prod_number DESC, date_of_sale DESC |
| result: SOLD at top/active at bottom/ALL in prod_number DESC Tried changing the order of code - kept getting the sold at top or mixed in with the active. FINALLY tried below. Didn't make sense to me but actually came closest to what I want. | ORDER BY date_of_sale ASC, status DESC, prod_number DESC |
| result: active at top of page/prod_number DESC/ALL sold at bottom in date_of_sale ASC. I'll use this one as it's the closest to what I want and much better than it was. If I change the date_of_sale to DESC it moves all sold back to top of gallery. Thanks so much! I learned some new coding I didn't know about and eventually (maybe) I'll figure out why I can't get sold items to be in date_of_sale DESC order, but for now this is great.
|
|