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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:21:44+00:00 2026-06-15T18:21:44+00:00

I am trying to connect tables by listing an id from another table into

  • 0

I am trying to connect tables by listing an id from another table into a specific field in a row in another table.

This is what I’m trying to do;

Table Items

Id   Name    Price
 1   Drink   5
 2   Food    3

Table Character

Id   Name   Cash   Inventory 
 1   Foo    10     1
 2   Bar    10     2
 3   Stu    10     1, 2

I am trying to reference the Items so that when I pull data concerning the Character ‘Stu’
It pulls the data associated with Items ‘1 & 2’ because he has them in his Inventory.

I’ve read up on Normalization and Foreign Keys but haven’t been able to find a way to tie them together in the fashion I want. I’ve also found the INT field will not accept multiple comma separated integers.

  • 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-15T18:21:45+00:00Added an answer on June 15, 2026 at 6:21 pm

    This should be easy using FIND_IN_SET looking at your table strructure here is the solution

    SELECT 
        * 
    FROM `characters` as c
    LEFT JOIN items as i on FIND_IN_SET(i.id, c.Inventory)
    WHERE c.name= 'Stu'
    

    EDIT :

    Here is the edited solution means one line solution.

    SELECT 
        c.* ,
        group_concat(i.name) as ItemName,
        group_concat(i.price) as ItemPrices         
    FROM `characters` as c
    LEFT JOIN items as i on FIND_IN_SET(i.id, c.Inventory)
    WHERE c.name= 'Stu'
    group by c.name
    

    If you are using php you can explode cell with php explode function and then loop through the cell to access all the cell values.

    EDIT :

    SELECT 
        c.* ,
        group_concat(i.id) as ItemIds,
        group_concat(i.name) as ItemName,
        group_concat(i.price) as ItemPrices         
    FROM `characters` as c
    LEFT JOIN items as i on FIND_IN_SET(i.id, c.Inventory)
    WHERE c.name= 'Stu'
    group by c.name 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my alter statement trying to connect two tables: ALTER TABLE my_contacts CHANGE
I am trying to connect to excel table from Delphi 7 using TAdoConnection component.
I'm trying to pull data from 2 tables and when I add this in
I am trying to connect to a database with two tables. However, after I
I am trying to write a query that connects 3 tables. The first table
Im trying to connect MySql from VB.NET in visual basic 2010. I wanted to
I'm trying to delete two tables rows from two different tables at once when
I'm trying to generate my database tables from my Entity Framework model, but I'm
I'm trying to follow this tutorial in order to connect to an external database
I'm using MySQL. I have 3 tables I'm trying to connect in a 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.