Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL newbie here, whats wrong with this

Author  Topic 

MonkeyBoy4u
Starting Member

2 Posts

Posted - 2010-08-23 : 13:41:28
I am new to SQL. So I have successfully ran this query

SELECT * from Customers
WHERE Country ='UK'

How do I select both countries UK and say USA

SELECT * from Customers
WHERE Country = ('UK' AND 'USA') does not work

Please help

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-23 : 13:44:36
[code]SELECT * from Customers
WHERE Country IN ('UK','USA')[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

MonkeyBoy4u
Starting Member

2 Posts

Posted - 2010-08-23 : 13:49:11
Thanks visakh, I had not read the "IN" operator as of now... jumped the gun a little bit
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-08-23 : 14:00:25
no probs. you may also do

SELECT * from Customers
WHERE Country ='UK'
OR Country ='USA'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -