how to use like operator for complex query in sqlite

database, sql, sqlite

Solution

This should do the trick:

select id, name
from table
where name like 'Ba%' or name like '% Ba%'

Problem

Hi all i have the following table called student in SQLite database. this is my table structure ``` id name ----------------------- "3" "Babu Qw" "2" "Ganesh Babu" "1" "Murali Abb" "4" "ganesh1 Babu" "5" "hari murali" "10" "Abbash abc" ``` name field is combined by first name and last name. for example "Babu Qw" Babu is the first name and Qw is the last name its separated by a space. and name is the input field where 'ba' is my input parameter.(Ex .. name like 'ba') now i want to fetch the records whatever name (first name or last name ) starts with 'ba' not by any middle character. output would be: ``` id name ----------------------- "3" "Babu Qw" "2" "Ganesh Babu" "4" "ganesh1 Babu" ``` here "Abbash abc" (first name Abbash or last name abc does not starts with ba) so that "Abbash abc" not listed.

Original source