OJuice
OJuice

Reputation: 465

MYSQL select multiple rows from same column and table

This question may seem a bit basic but can't seem to Google it up. Maybe it's too basic, no one bothered to make a article or forum post about it.

Anyway, I have a table called locations. I wish to call the row with the value 1, 2 and 3 from the same column. I have been using this method so far:

SELECT * FROM locations WHERE location_id='1' OR location_id='2' OR location_id='3'

However, is there a much simpler way without typing it out all over again. It is the same column afterall.

Upvotes: 1

Views: 1364

Answers (1)

sumit
sumit

Reputation: 15464

SELECT * FROM (table name) where (column name) in [first row,second row]

when [] brackets used then put () brackets when () brackets used then don't put brackets

Upvotes: 8

Related Questions