Reputation: 1
SELECT c.LastName,
c.FirstName,
i.InvoiceId,
i.CustomerId,
i.InvoiceDate,
i.BillingCity,
i.total
FROM invoices i
INNER JOIN customers c ON i.CustomerId=c.CustomerId
WHERE BillingCity LIKE 'P%' OR 'S%'
I am trying to find records from the cities that start with P and S. When I run this query, It only returns the cities with P.
Upvotes: 0
Views: 48
Reputation: 652
Try this:
SELECT c.LastName,
c.FirstName,
i.InvoiceId,
i.CustomerId,
i.InvoiceDate,
i.BillingCity,
i.total
FROM invoices i
INNER JOIN customers c
ON i.CustomerId=c.CustomerId
WHERE (i.BillingCity LIKE 'P%' OR i.BillingCity LIKE 'S%')
Upvotes: 0
Reputation: 93636
Your WHERE clause is incorrect. You can't say "LIKE this OR that". You need two different LIKE expressions, joined with an OR.
WHERE
BillingCity LIKE 'P%'
OR
BillingCity LIKE 'S%'
Upvotes: 3