Jump to content

Help writing a special SQL query


imri

Recommended Posts

Hey there!

 

I need help writing a special SQL query.

 

I have a table of Events, every event contains a user-id, which is the id of the creator.

 

Every user in my website chooses 3 colors he likes. I want to select Events from the events table,

ordering it by colors match - an event, which it's creator's colors match my colors best, will be "ranked" higher.

 

For example, if John created an event X, and John's colors are Green, Red and Yellow, and my colors are Red, Orange and Yellow,

his event will be higher in the results list, than event which Paul created, because Paul's favorite colors are Black, Blue and Red.

 

There is a users-colors table, which consists of user-id and color-id.

 

I hope I explained myself best.

 

Thanks in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.