Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to FIND_IN_SET in SQLite?

Tags:

php

sqlite

mysql

In Mysql, FIND_IN_SET is used to find value in a set. I have tried FIND_IN_SET in SQLite, but it is not an SQL keyword. I have Googled, but I did not get an answer. If anybody knows, please tell me the alternative to FIND_IN_SET in SQLite.

like image 541
Balaji Kandasamy Avatar asked Dec 01 '22 07:12

Balaji Kandasamy


2 Answers

If you need just a true / false value rather than index then you can use LIKE clause:

(',' || column_name || ',') LIKE '%,value,%'
like image 57
Karolis Avatar answered Dec 04 '22 13:12

Karolis


we can write query like change into hibernate critearea

my old query

select * FROM game_detail WHERE content_id=176 and FIND_IN_SET(12,group_master_id)

New query

select * 
  FROM game_detail
 WHERE content_id=176
   and (group_master_id LIKE '%12,%'|| group_master_id LIKE '%,12,'|| group_master_id LIKE '%12')
like image 24
sanjay patidar Avatar answered Dec 04 '22 14:12

sanjay patidar