0
My User Table is :

    ID.   NAME.  EXPERTISE
    1.    Aman.   1, 2
    2.    Deep.   2, 3, 4
    3.    Singh.  1, 3

Question: I want to apply search operations on Expertise. Query and Results both should be comma separated. Like Search Users who is having EXPERTISE (2,4). How I can Write query in MySQL.

Then response should be ID -> 1,2

INPUT - > Select ID from User where EXPERTISE (2,4)
OUTPUT -> ID (1,2)

ID
1,2
  • To use columns with comma-separated values in SQL is to **misuse** SQL. If you have any possibility of doing so, add a new table for expertise. Read about one-to-many relationships. – O. Jones Sep 26 '20 at 10:59
  • You might want to get rid of the column with comma-separated values, see https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad – Progman Sep 26 '20 at 12:33
  • I solved this with REGEXP ',?[2,4],?' – Deep Dahelay Sep 26 '20 at 12:43

0 Answers0