Forum Moderators: coopster

Message Too Old, No Replies

MySQL question

Can you have multiple WHERE, ORDER BY commands for a single mysql query?

         

acidic

4:13 pm on Aug 29, 2003 (gmt 0)

10+ Year Member



Hey!

Just a little MySQL question: Can you have multiple WHERE, ORDER BY commands for a single mysql query? Let me try clarifying what I mean: I store title and descriptions of all games in my freeware game directory, for a search of the database of games I want to select games where their rating is between 90 and 100 and the query string comes up in their title, then I want to select games with ratings between 90 and 100 that have the query string in their description, then with ratings between 70 and 90 that have the query string in their title and so on… and the result would be one nicely packaged mysql result set without any games being repeated.

I can think of a pretty easy way to do this using outside php code but I would rather use a big bad mysql query so that I can have multiple search results pages my using LIMIT.

Thanks a lot.

bcc1234

4:20 pm on Aug 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



...where (a=b) and ((c<>d) or (c<>e)) and (f<>g) order by h,i desc, j limit k

acidic

8:08 pm on Aug 29, 2003 (gmt 0)

10+ Year Member



OK, I understand most of that, just not the "order by h,i desc, j" What do the commas do?

justageek

8:10 pm on Aug 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nothing :-)

acidic

8:23 pm on Aug 29, 2003 (gmt 0)

10+ Year Member



Aaah, just saw it in the reference manual: order by the first item then by the second... that could be useful. Strange that my stupid PHP didn’t have any info on that.

coopster

3:27 pm on Aug 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Strange that my stupid PHP didn’t have any info on that.
Why? Because ORDER BY is a function of MySQL, not PHP ;)