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.
CodePudding user response:
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%'
CodePudding user response:
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%')