2

I am developing an iphone app which has its backend in Sqlite. I want to search a pattern from the db table. I used the following query for that

SELECT roman,walpha FROM gurbani where walpha LIKE 'rm rs% p%'

My requirement is the results should contain first word 'rm', second word starting with 'rs' and the third word must start with 'p'.

The following is a screen shot of the result of my sql query

enter image description here

Here in my results the lines in walpha 3,6 and 7 are wrong, as I want the third word to be starting with the letter'p'. This is because of the use of 'rs%' in the sql query. So I tried another query as follows:

SELECT roman,walpha FROM gurbani where walpha LIKE 'rm rs p%'

But this results only the 4th line in the above screenshot. I am new in Sql. Is there any other method for search my pattern ?

Vishnu Kumar. S
  • 1,797
  • 1
  • 15
  • 35
  • You could use an appropriate regular expression for your query. See: http://stackoverflow.com/questions/5071601/how-do-i-use-regex-in-a-sqlite-query – Arxo Clay Jun 05 '13 at 05:54

1 Answers1

-1

select roman,walpha from gurbani where walpha like 'rm%rs%p%'

try this it should definitely work for your requirement.

kiran
  • 1
  • 1
    No..This cannot be done. While using wildcars it will not ensure the positions of the words, that means any words or characters can be there in the '%' – Vishnu Kumar. S Jun 05 '13 at 06:32