krunal patel
krunal patel

Reputation: 13

what is the sql query to search a containing word using like

I am using sql query using like but it is not returning any thing in below code

NSString *strSelectQuery = [NSString stringWithFormat:@"SELECT * FROM tblrestaurant WHERE address LIKE '%@'",txtField.text];

Upvotes: 1

Views: 99

Answers (2)

Ikambad
Ikambad

Reputation: 104

SELECT * FROM yourtable WHERE Name like '%%%Searchterm%%'

Upvotes: 0

rmaddy
rmaddy

Reputation: 318824

You need % characters around the search text. Try this:

NSString *strSelectQuery = [NSString stringWithFormat:@"SELECT * FROM tblrestaurant WHERE address LIKE '%%%@%%'",txtField.text];

Note that the % symbols are escaped. So yes, that is three %, then the @, and then two more %.

Upvotes: 4

Related Questions