Im trying to do this and almost got it except for one small issue
Take one row as example :
field1 - contains 'aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii,jjj'
field2 - contains '1001101001'
Need to search for position of 'ggg' in
field1 if it exists. (7 in this case and 0 if not found)
If it does exists then get that position's bit in
field2 (7th bit is 1 in this case)
This can be done using :
Code: Select all
SELECT FIND_IN_SET('ggg',field1),SUBSTRING(field2,FIND_IN_SET('ggg',field1),1) FROM `table1`
But I want to check is : if 'ggg' does not exist then FIND_IN_SET('ggg',field1) will return 0 and its no point in continuing with SUBSTRING(field2,FIND_IN_SET('ggg',field1),1)
How am I suppossed to get of that ?
Thanks