I have a table names Users, each user has hobbies inside Hobbies field. I want to find users with matching hobbies,
The hobbies are stored like this:
id | username | hobbies 1 | Ben | Hiking, Surfing 2 | Jane | Surfing, 3 | Dan | Reading
I want to sort the table by the matching user's hobbies - so the result will be something like :
HobbieName (Hiking) | id | username | 1 | Ben | 2 | Jane
Is it possible to do with MySql query or should I sort the data by PHP ?
SELECT * FROM `Hobbies` WHERE `hobbies` LIKE `%Hiking%` ORDER BY `id` DESC ;
Hobbies is your table.
hobbies is your column in
LIKE try to get all result contains the text
%Hiking% will search for any world contain
Hiking like these examples :
My Hiking is
Hiking is best