LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Mysql SELECT WHERE LIKE (https://www.linuxquestions.org/questions/linux-software-2/mysql-select-where-like-303827/)

ivanatora 03-20-2005 04:25 AM

Mysql SELECT WHERE LIKE
 
I want to use AND and OR to select some stuff that I need from a table. I've done this:
mysql> SELECT * FROM msgs WHERE nick LIKE 'ivanatora' OR nick LIKE 'anga%'; <= works fine
mysql> SELECT * FROM msgs WHERE nick LIKE 'ivanatora' AND msg LIKE 'test%'; <= too
mysql> SELECT * FROM msgs WHERE nick LIKE 'ivanatora' OR nick LIKE 'anga%' AND msg LIKE 'test%'; <= this one shows all where nick is like 'ivanatora'
But I want to combine some more ANDs and ORs to make my selection more exact. My question is: how all these combinations prioritized? Does the ANDs are compared before ORs or vice versa?

Cornholio 03-20-2005 04:45 AM

You just have to use brackets... it's like math :-)

(x || y) && z

x || (y && z)

You know what I mean?

Greetings, Sascha

ivanatora 03-20-2005 10:57 AM

Thanks, it worked :)

Cornholio 03-20-2005 11:43 AM

Glad I could help you :-)


All times are GMT -5. The time now is 08:28 PM.