Hi I'm creating a website that uses a count query, to see how many things in the database match a variable.
Table eg:

Whats Liked User Liked By
potatoes djiajgi
computer djiajgi
.........

Now, I'm trying to see people who like the same thing as you do, and am ordering them by the amount of things you have in common. Lets say you like potatoes and computers as well. It will display djiajgi, djiagi two times. I'd like it to appear only once like here http://sqlfiddle.com/#!2/b6f78/8 How would I go about doing this, so if I like computer and potatoes, it will display djiajgi only once? Code :

$people_like = mysqli_query ($link, "SELECT COUNT(user_liked_by) AS total, id, user_liked_by
FROM whatilike WHERE whats_liked LIKE '%$thing_liked%' && user_liked_by !='$user'
GROUP BY user_liked_by   
ORDER BY COUNT(user_liked_by) DESC; ");

maybe a subquery
see Click Here

    SELECT user_liked_by FROM ( 
        SELECT COUNT(user_liked_by) AS total, id, user_liked_by
        FROM whatilike WHERE whats_liked LIKE '%$thing_liked%' &&
        user_liked_by !='$user'
        ORDER BY COUNT(user_liked_by) DESC ) as names 
    GROUP BY user_liked_by;

not sure what this will do to the ORDER BY part

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.