Posted By

the_construct on 01/05/12


Tagged

mysql sql where


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

seagleye


Where clause to select multiple rows of unique values


 / Published in: SQL
 

Where clause to select multiple rows of unique values

  1. --- YOU WANT TO SELECT MULTIPLE ROWS AT ONCE BASED ON UNIQUE VALUES
  2. --- some_id IS THE COLUMN NAME THAT MAY HAVE AN ID THAT YOU WANT TO BASE THE SELECTION ON
  3.  
  4.  
  5. --- IN PLAIN ENGLISH YOU ARE SAYING...
  6. --- SELECT ALL THE ID'S (IN PARENTHESES) FROM THE COLUMN NAMED some_id
  7.  
  8. SELECT * FROM `your_table_name` WHERE some_id IN(1165,1166,1180,1181)

Report this snippet  

You need to login to post a comment.