Sandy Pabilonia
Sandy Pabilonia

Reputation: 79

How to Query Multiple Values in two columns

I would like to check if two or more certain values like firstname and lastname is in my database.

Select * from client_info 
where (first_name = "John" and last_name ="Smith")
and   (first_name = "Donald" and last_name ="Trump")
and   (first_name = "Baracj" and last_name ="Obama")

Thanks in advance

Upvotes: 0

Views: 952

Answers (2)

Orest
Orest

Reputation: 6748

Execute this query and if result is >= 2 then you have both rows in a table

SELECT COUNT(*) FROM (SELECT DISTINCT first_name, last_name FROM client_info
                      WHERE (first_name = "John" AND last_name ="Smith")
                         OR (first_name = "Donald" AND last_name ="Trump")
                         OR (first_name = "Baracj" AND last_name ="Obama")) AS ci

Upvotes: 0

sunkuet02
sunkuet02

Reputation: 2442

You can Try this:

Select * from client_info 
      where (first_name = "John" and last_name ="Smith")
           or (first_name = "Donald" and last_name ="Trump")
           or (first_name = "Baracj" and last_name ="Obama")

Upvotes: 2

Related Questions