
Question:
I have TBL_STD_FIELD_VALUE table, in that FLD_USER_IDS column is present. It's datatype is varchar(255). I am storing email ids separated by ',' in that column.
Below is FLD_USER_IDS column values.
<img alt="Query one" class="b-lazy" data-src="https://i.stack.imgur.com/0hY0l.png" data-original="https://i.stack.imgur.com/0hY0l.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />
I want to retrieve rows, in which FLD_USER_IDS column contains <strong>'akshay_goel2013@isb.gappspilot.info'</strong> entry.
Below is my sql query
select fieldValues.FLD_USER_IDS from TBL_STD_FIELD_VALUE as fieldValues where 'akshay_goel2013@isb.gappspilot.info' IN (fieldValues.FLD_USER_IDS)
But it is not giving any result. is something wrong in it.?
Answer1:You have to use FIND_IN_SET
for more information see the <a href="http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_find-in-set" rel="nofollow">documentation</a>
This query should give you the correct result:
select fieldValues.FLD_USER_IDS from TBL_STD_FIELD_VALUE as fieldValues where FIND_IN_SET ('akshay_goel2013@isb.gappspilot.info',fieldValues.FLD_USER_IDS)