i have a problem in mysql query.
this is how my tables looks like:
mysql> select username, specialty from users;
+----------+------------------+
| username | specialty |
+----------+------------------+
| JinkX | php, html, mysql |
| test1 | html |
+----------+------------------+
mysql> select name, tags from tasks;
+----------------+------+
| name | tags |
+----------------+------+
| fix front page | html |
+----------------+------+
and when i try to do the following query, it works only if the specialty equals exactly the tags. but i want it to work on both
mysql> select tasks.name from users left join tasks on tasks.tags LIKE users.specialty where users.username = 'test1';
+----------------+
| name |
+----------------+
| fix front page |
+----------------+
mysql> select tasks.name from users left join tasks on tasks.tags LIKE users.specialty where users.username = 'JinkX';
+------+
| name |
+------+
| NULL |
+------+
Well, you’ve discovered the pain of saving independent values as a comma-delimited string.
If you can, I would suggest that you change your data structure, get the specialty column out of the user table, and create a new
user_specialtytable that would have foreign keys tousers.usernameandtasks.tags.