Reputation: 95
I want to display a List of Instructors with only first name and last name, from Georgia and whose last name ends in ‘son’.
I have written this so far:
SELECT firstname, lastname, state
FROM instructors
WHERE state = 'ga'
AND lastname LIKE '%son'
But it is not returning the information requested just a blank table.
Any help would be greatly appreciated
Upvotes: 0
Views: 448
Reputation: 95
FINALLY !!!!!
I Figured It Out!
SELECT firstname, lastname, state
FROM instructors
WHERE state = 'ga'
AND lastname LIKE '*son*'
Instead of using the %WildCard I inserted *WildCard on both ends and it displayed exactly what I was requesting !
Thanks Everyone For Your Help!
Upvotes: 0
Reputation: 2016
To find names ending in 'son' you need to make a small change and remove the second '%' sign. with both it looks for 'son' any where such as 'sonnentag'
The second one I would guess that the DB has Georgia as 'GA' not 'ga'. Case is important.
SELECT firstname, lastname, state
FROM instructors
WHERE state = 'GA'
AND lastname LIKE '*son'
Upvotes: 4
Reputation: 61
This should works to you.
SELECT [firstname],[Lastname],[state]
FROM instructors AS i
WHERE i.state = 'ga' AND i.lastname LIKE '%son'
Upvotes: -1
Reputation: 20794
This is a formatted comment that shows you how to troubleshoot. Start with this:
SELECT firstname, lastname, state
FROM instructors
WHERE 1 = 1
-- and state = 'ga'
--AND lastname LIKE '%son'
If that returns no records, you have no data. If it does, uncomment the two other filters, one at a time, to see which one causes no records to be returned. It could well be that you simply have no matching records
Upvotes: 0