Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL 'ends-with' Command

Tags:

sql

I'm querying a database to select strings which end in a certain substring, such as yahoo.com.

To select equal strings, I would call select * from users where email='[email protected]'.

How do I select users whose emails end in yahoo.com?

like image 912
Jared Nielsen Avatar asked Dec 03 '22 19:12

Jared Nielsen


1 Answers

If you use a like search and DO NOT put a percent on the end, it is effectively an "ends with".

Select * from users where email like '%yahoo.com'
like image 164
George Mastros Avatar answered Dec 31 '22 01:12

George Mastros