Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I select rows where a column value starts with a certain string?

Tags:

sql

sqlite

How do I select rows where a column value starts with a certain string ?

For example, I'd like to select the rows whose 'name' column starts with "Mr.".

like image 960
Phillip Avatar asked Jul 04 '12 19:07

Phillip


People also ask

How do I SELECT a row from a specific value in SQL?

To select rows using selection symbols for character or graphic data, use the LIKE keyword in a WHERE clause, and the underscore and percent sign as selection symbols. You can create multiple row conditions, and use the AND, OR, or IN keywords to connect the conditions.


1 Answers

You can do

select * from mytable where name like "Mr.%" 

See http://www.sqlite.org/lang_expr.html

like image 126
Denys Séguret Avatar answered Sep 23 '22 06:09

Denys Séguret