Jina Huh
Jina Huh

Reputation: 59

Retrieving multiple rows in MySQL

I have a list of hand listed uniqueID that I want to retrieve from my MySQL database. As of now, I'm using:

Select * from TABLE where uniqueID = "111" or uniqueID = "124" or uniqueID = "220"...

Obviously this is very time consuming. The list of uniqueID is not written in any file. I just want more efficient query to tell the database to retrieve the rows with the uniqueIDs. Is there something like,

Select * from TABLE where uniqueID = {"111", "124", "220"...}

that I could use?

Thank you.

Upvotes: 0

Views: 93

Answers (2)

Zach Kemp
Zach Kemp

Reputation: 11904

SELECT * from table WHERE uniqueID IN (111,123,220);

Upvotes: 1

Joe Stefanelli
Joe Stefanelli

Reputation: 135808

Select * from TABLE where uniqueID IN ('111','124','220',...)

Upvotes: 3

Related Questions