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 8289125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:26:12+00:00 2026-06-08T12:26:12+00:00

For instance I have table A and table B a.data = {1,2,3,4,5,6} b.data =

  • 0

For instance I have table A and table B

a.data = {1,2,3,4,5,6}
b.data = {4,5,7}

If you want to lookup one value in a.data or b.data you can use FIND_IN_SET(3, b.data).
But I want to know if at least all the values of b.data are in a.data, or else if I can find
at least the intersection between b.data and a.data. So in this case {4,5}.

WHERE INTERSECT(a.data, b.data) … something like that. How should I do this in MySQL?

update

The b.data {4,5,7} is the column data of one 1 record, so joining a.data on b.data won’t work.

table A  
=======
ID     DATA  
1      {1,2,3,4,5,6}  
2      {7,9,12}  

table B  
=======  
ID     DATA  
1      {4,5,7}  
2      {9,10,11,12}
  • 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-08T12:26:14+00:00Added an answer on June 8, 2026 at 12:26 pm

    You can take interection of tables using INNER JOIN

    have a look at Visual explaination of joins

    SELECT fn_intersect_string(a.data, b.data) AS result FROM table_name;
    

    also you can write a user defined function as:

    CREATE FUNCTION fn_intersect_string(arg_str1 VARCHAR(255), arg_str2 VARCHAR(255))
    RETURNS VARCHAR(255)
    BEGIN
        SET arg_str1 = CONCAT(arg_str1, ",");
        SET @var_result = "";
    
        WHILE(INSTR(arg_str1, ",") > 0)
        DO
            SET @var_val = SUBSTRING_INDEX(arg_str1, ",", 1);
            SET arg_str1 = SUBSTRING(arg_str1, INSTR(arg_str1, ",") + 1);
    
            IF(FIND_IN_SET(@var_val, arg_str2) > 0)
            THEN
                SET @var_result = CONCAT(@var_result, @var_val, ",");
            END IF;
        END WHILE;
    
        RETURN TRIM(BOTH "," FROM @var_result);
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this data in a table, for instance, id name parent parent_id 1
I'm trying to update a table to remove all but the first instance of
I have produced a data table. All the columns are sortable. It has a
Let’s say I have table/list like this n=3 in this case, but n can
I need to store a lookup table as an instance member in one of
Rookie question I know. I have a table with about 10 fields, one of
I'm designing a table on view. For instance, they have two columns are ID
I have read the (excellent) documentation but I can't figure out how to do
I have a table of heterogeneous pieces of data identified by a primary key
Suppose I have a table that contains valid data. I would like to modify

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.