Pankaj Pankaj - 6 months ago 8
SQL Question

Query for before or after the characters

I am using Sqlite for a personal application and I have got a simple query

Select Name from Employees where Name (Name LIKE '%aj%')


It returns me results

Pankaj
Neeraj
Saajan


but this query

Select Name from Employees where Name (Name LIKE 'aj%')


doesn't returns anything, I guess It should returns

Pankaj
Neeraj


as they both ends with 'aj'. I want all the entries which ends with 'aj'.

Couldn't figure out whats wrong here or Sqlite doesn't support single ampersand (%) queries ?

Answer
Select Name from Employees where Name LIKE '%aj'

You should place your wildcard in front of the wanted chars.

A wildcard character can be used to substitute for any other character(s) in a string.

Comments