Reputation: 11
I am having a hard time with SQL. I am using this demo of SQL here
but I cannot figure out how to list only companies that begin with A or F along with address and city. Can someone help me please?
Upvotes: 1
Views: 166
Reputation: 342
You could use the like operator which would use an index if present.
SELECT CompanyName, ContactName, Address, City
FROM customers
WHERE CompanyName like '[af]%'
Upvotes: 1
Reputation: 2543
http://msdn.microsoft.com/en-us/library/ms187748.aspx
where lower(substring(title,0,1)) in ('a', 'f')
Upvotes: 0
Reputation: 70523
SELECT CompanyName, ContactName, Address, City
FROM customers
WHERE lower(substring(CompanyName,0,1)) in ('a','f')
Upvotes: 0