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
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'
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
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!
This should works to you.
SELECT [firstname],[Lastname],[state]
FROM instructors AS i
WHERE i.state = 'ga' AND i.lastname LIKE '%son'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.