Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8205325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:11:38+00:00 2026-06-07T08:11:38+00:00

A column in my MySQL setup is called favColors. It’s just a VARCHAR column

  • 0

A column in my MySQL setup is called favColors. It’s just a VARCHAR column where I’m saving a JSON string with the favColors for each user. Pretty simple.

Let’s say this is User A’s favColors:
["red","green","cyan","silver","gold"]

And this is user B’s favColors:
["pink","green","blue","brown","yellow"]

And this is user C’s favColors:
["tan","green","blue","brown","yellow","violet"]

And user B wants to query to find other users that share the same colors. But i’m interested in finding the BEST match.

I figure I could use something like this…
WHERE MATCH (favColors) AGAINST ('$userBsJSONString' IN BOOLEAN MODE)

but, I’d like to have the results retuned ordered by which rows had the most matches, and id like to know what colors they were a match on.

So basically I could do something like “hey you both like “green”,”blue”,”brown”,”yellow”!

What would be the best way to go about a query that can return this information?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:11:40+00:00Added an answer on June 7, 2026 at 8:11 am

    You can’t with the current data layout.

    You’ve get extremely un-normalised data here. To do the kind of analysis you want, you need two more tables.

    The first table would be of colour. Each colour would have a unique ID and the colour name.

    The next table would be an association table. Each row would be a user ID and a colour ID, indicating that that user likes that colour.

    Then, a query like:

    SELECT userID, COUNT(colourID) FROM associationTable 
       WHERE colourID IN (<list of IDs that belong to user of interest)
       GROUP BY userID
    

    For each userID, you’d have a count of the number of colours that matched. The higher the number, the better the match

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to read my blob column from mysql to string type in hibernate I
If your goal is to test if a string exists in a MySQL column
I have a table setup with a UNIQUE column called, for example, test .
So I have a database setup in MySQL with three columns. The first column
I have a MySQL column specified as: `type` TINYINT(1) NOT NULL DEFAULT '0' The
I have a column in mysql which stores the dates. So in mysql the
I have a DATE datatype mysql column in a table. I want to set
Suppose I have a datetime column in MySQL. How do I select all that
by default I have one column in MySQL table to be NULL. I want
Hi every One I am trying to add column in Mysql. My Sql Query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.