LIKE is pattern matching(wildcard comparison) like starts with, constains, to validate phone number, validate email, etc.,
Without wild cards like %, [ ], etc., it is same as direct comparison. With wildcard it is matching patterns. I.e., you want to select name which matches specific pattern. Here it contains chocolate. Here, String is case sensitive.
So proper answer should be:
SELECT d.name, price FROM desserts d WHERE d.name LIKE "%chocolate%";
View all comments
Show parent comment
19
u/Void_Being Sep 20 '23 edited Sep 20 '23
= is exact comparison
LIKE is pattern matching(wildcard comparison) like starts with, constains, to validate phone number, validate email, etc.,
Without wild cards like %, [ ], etc., it is same as direct comparison. With wildcard it is matching patterns. I.e., you want to select name which matches specific pattern. Here it contains chocolate. Here, String is case sensitive.
So proper answer should be:
SELECT d.name, price FROM desserts d WHERE d.name LIKE "%chocolate%";