WHERE... LIKE and how it works with other code


#1

Hi Codecademy,

I am working through the Davie’s Burgers Subway Ad exercises in SQL. I have a question in SQL, how does the WHERE… LIKE code works, and how it interacts with other code. Why does it work in some instances. For example:

This code here does not work:

SELECT DISTINCT special_instructions
FROM orders
WHERE special_instructions IS NOT NULL
WHERE special_instructions LIKE ‘%sauce%’
ORDER BY special_instructions ASC;

But this code does work:

SELECT special_instructions
FROM orders
WHERE special_instructions LIKE ‘%sauce%’;

Thanks for all of your help,

Eric


#2

You can’t have more than 1 WHERE clause as far as I’m aware. You should use AND:

WHERE special_instructions IS NOT NULL 
    AND special_instructions LIKE ‘%sauce%’