lundi 11 juillet 2016

SQL - print names with letter starting in 's' or ending in 's'. Exclude Males

I'm writing an SQL command to display pet names that start or end with the letter 's' and exclude all males from the output list.

I have no idea how to exclude males from the list. I have a column called Gender which hols the gender of the pet. This is either M = Male, F = Female and X = other.

My understanding is that s% is checking for s at the start of a name and %s is checking for an s at the end of the name. Below is my command so far.

SELECT pet_id, Name, Type, Breed, Gender
FROM pet
WHERE Name LIKE 's%' OR Name LIKE '%s'  

Aucun commentaire:

Enregistrer un commentaire