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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:42:31+00:00 2026-06-02T18:42:31+00:00

Working with MySQL, I’ve got two tables – one with videos, the other with

  • 0

Working with MySQL, I’ve got two tables – one with videos, the other with products. Each row in the products table has a column called productVideoOrder, which is a comma separated list of videoIDs (relating to the video table) in the order that the user has placed them.

What I describe below would be easier if the relationship was in an intermediate table, but for other functions of this project, the comma separated list made sense.

I’m trying to get a table that returns column one: videoTitle, column two: productName. Is there a way to left join based on a comma separated list? I would like the results table to allow repeated rows, for example, if two product lists video one in the productVideoOrder, this table would have two rows for that video, one listing product one, the other listing product two.

I can clarify anything needed. Thanks in advance!

  • 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-02T18:42:33+00:00Added an answer on June 2, 2026 at 6:42 pm
    SELECT  p.name, v.title
    FROM    product p
    LEFT JOIN
            video v
    ON      FIND_IN_SET(v.id, p.productVideoOrder)
    

    This is not going to be fast.

    If you have some reasonable limit on the number of videos which can be assigned to a product, you may try using this:

    SELECT  p.name, v.title
    FROM    product p
    CROSS JOIN
            (
            SELECT  1 AS n
            UNION ALL
            SELECT  2 AS n
            UNION ALL
            SELECT  3 AS n -- add more if needed
            )
    LEFT JOIN
            video v
    ON      v.id = SUBSTRING_INDEX(SUBSTRING_INDEX(productVideoOrder, ',', n), ',', -1)
            AND SUBSTRING_INDEX(SUBSTRING_INDEX(productVideoOrder, ',', n), ',', -1) <> SUBSTRING_INDEX(SUBSTRING_INDEX(productVideoOrder, ',', n - 1), ',', -1)
    

    This will be using an index on v.id.

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

Sidebar

Related Questions

I've been working on some MySQL Joins but this one has got me a
Working with MySQL database. I have a store table. The store table has at
I am working with MySQL version 5. I have two tables structured as shown
I'm working on mysql and have two tables with the same schema: preTrial |id|accusedId|articleid|
I am working on a MySQL database that is huge (about 120 tables). I
I'm working with MySQL connector and C#. Everything was ok until I got to
i'm working on mysql those are my tables D ---------- id , name ----------
I am working with mysql . I have checked the CREATE table statement ,
I am working with mysql and php and have a Parent Child table created
I'm working with MySQL databases. To simplify the problem, let's say I have two

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.