0
  • table name table1,
  • primary column column 1,
  • column name column2,
  • data in column2 '1,2,3' where column1=1.

Query:

select `id` 
from `table2` 
where `id` IN (select `column2` from `table1` where `column1`=1)

I found the following way to solve this till now,

  1. I can run the subquery separately.
  2. Use the find_in_set() function.

As find_in_set is non-sargable I was looking for a solution where I can do this within one query.

Barmar
  • 741,623
  • 53
  • 500
  • 612

0 Answers0