Reputation: 5746
My MySQL field having skills field(string) like,
1)php,mysql
2)java
3)java,c
I need to select the column with skills field condition. Condition may be Like,
skills="php" // o/p => 1st column
or
skills = "mysql,c" // o/p => 1st and 3rd column
How I can write Query.? Here im using PHP.
Upvotes: 0
Views: 2555
Reputation: 10444
Use a procedure like this one:
Split comma separated values from one column to 2 rows in the results. MySQL
To split your csv skills field into a temp table with rows for each skill
Then do the same thing with your search parameters (which I assume is also csv string passed in)
Then simply apply a JOIN
over the two results and get the DISTICT
Id.
there are many solutions for splitting a comma separated string in MySQL (though it's not particularly good at this task)... if you can't properly normalize the data then you can't very well complain about inefficient query routines.
Upvotes: 1