7

I have a query say SELECT name,number FROM TABLE WHERE number='123'
What I want is to display multiple records using where clause or any other way so that I can get following data.

Name Number ABC 123 PQR 127 PQR 130

I tried using AND && , in where clause.i.e. where number=123,127,130 or where number=123 AND 127 AND 130etc. but nothing works.

0

3 Answers 3

13

just use an IN clause

where number in (123, 127, 130)

you could also use OR (just for info, I wouldn't use this in that case)

where number = 123 or
      number = 127 or
      number = 130

Don't forget round braces around the "ors" if you have other conditions in your where clause.

Sign up to request clarification or add additional context in comments.

Comments

2

Try this

SELECT name,number FROM TABLE WHERE number IN (123,127,130);

OR

SELECT name,number FROM TABLE
                   WHERE number = 123
                   OR number = 127
                   OR number = 130;

Comments

-1

you can use where in to get multi record like this,

select * from table name
WHERE COLUMN_NAME IN ('12','23','43','46');

Result will be :

COLUMN_NAME
12
23
43
46

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.