LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 03-20-2005, 05:25 AM   #1
ivanatora
Member
 
Registered: Sep 2003
Location: Bulgaria
Distribution: Ubuntu 9.10, FreeBSD 7.2
Posts: 459

Rep: Reputation: 31
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?
 
Old 03-20-2005, 05:45 AM   #2
Cornholio
Member
 
Registered: Dec 2004
Location: Alemania
Distribution: Slackware 10.0
Posts: 115

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

(x || y) && z

x || (y && z)

You know what I mean?

Greetings, Sascha
 
Old 03-20-2005, 11:57 AM   #3
ivanatora
Member
 
Registered: Sep 2003
Location: Bulgaria
Distribution: Ubuntu 9.10, FreeBSD 7.2
Posts: 459

Original Poster
Rep: Reputation: 31
Thanks, it worked
 
Old 03-20-2005, 12:43 PM   #4
Cornholio
Member
 
Registered: Dec 2004
Location: Alemania
Distribution: Slackware 10.0
Posts: 115

Rep: Reputation: 15
Glad I could help you :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
php mysql select msound Programming 9 05-21-2005 09:44 PM
MySQL Select Count Question robgo777 Programming 9 01-07-2005 06:54 AM
SELECT on MySQL Help Gerardoj Programming 5 05-29-2004 03:17 AM
mysql replicates, possible to SELECT only one per value? SerfurJ Programming 7 03-26-2004 12:35 PM
select the last x record added into mysql meluser Programming 3 04-14-2003 04:37 PM


All times are GMT -5. The time now is 01:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration