Jump to content


Photo

Query Syntax


  • Please log in to reply
2 replies to this topic

#1 jaymc

jaymc
  • Members
  • PipPipPip
  • Advanced Member
  • 1,521 posts
  • LocationLiverpool

Posted 07 October 2006 - 01:07 PM

Ok, basically I want to run 1 query and search for where ID rows = 5 different numbers

So essentially it is going to search the entire table and try pull out 5 different rows based on my search criteria

Is this the syntax for that

SELECT * 
FROM `artists` 
WHERE `ID` = '1'
AND `ID` = '4'
AND `ID` = '7'
AND `ID` = '21'
AND `ID` = '51'
LIMIT 0,5

I just thought their may be another way rather than using all those ANDS

maybe something like

WHERE ID = '1,4,7,21,51'

Any help?
I would love to change the world, but they won't give me the source code

SEO Agency

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 07 October 2006 - 01:15 PM

SELECT * FROM artists WHERE ID IN (1,4,7,21,51) LIMIT 0,5

Legend has it that reading the manual never killed anyone.
My site

#3 jaymc

jaymc
  • Members
  • PipPipPip
  • Advanced Member
  • 1,521 posts
  • LocationLiverpool

Posted 07 October 2006 - 02:21 PM

Worked
I would love to change the world, but they won't give me the source code

SEO Agency




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users