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

The Archive Base Latest Questions

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

I have 2 tables. One table contains a person’s name and that person’s unique

  • 0

I have 2 tables. One table contains a person’s name and that person’s unique ID. The other table has multiple columns, but there is one column in particular that stores the person’s unique ID.

Until now, the 2nd table has always stored a single ID, so I was able to easily perform JOINs on these two tables and get the data I needed like so:

SELECT DISTINCT personTable._id, personTable.name FROM dataTable LEFT OUTER JOIN personTable ON dataTable.person_id = personTable._id

However, a new requirement came into play that now will allow the 2nd table to reference more than one ID in the same column. In other words, the table used to be strictly like this:

2ND TABLE COLUMN PERSON'S ID = 5

But now the storage can be like this

2ND TABLE COLUMN PERSON'S ID = 5-6
2ND TABLE COLUMN PERSON'S ID = 5-3-8-2
2ND TABLE COLUMN PERSON'S ID = 5 (still valid)

With this new format, I can not query data successfully each time. How can I update this query to work properly? I am using SQLite in Android. Thanks for any help.

  • 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-15T00:44:52+00:00Added an answer on June 15, 2026 at 12:44 am

    You will not get far if you use new format.

    To serve new spec, you should change your schema to have one more table which will serve as join table.

    In total, you will have 3 tables, something like this:

    CREATE TABLE persontable (
        person_id INTEGER PRIMARY KEY,
        name VARCHAR(32),
        -- more person fields...
    )
    
    CREATE TABLE datatable (
        data_id INTEGER PRIMARY KEY,
        join_id INTEGER,
        -- more datatable fields...
    )
    
    CREATE TABLE jointable (
        join_id INTEGER PRIMARY KEY,
        person_id INTEGER
    )
    

    Jointable will have as many rows per user as you need, for example for

    2ND TABLE COLUMN PERSON’S ID = 5-3-8-2

    it will have 4 rows.

    Now, you can have your data as follows:

    SELECT d.*,
        p.name,
        ...
    FROM datatable d
        JOIN persons p USING (person_id)
        JOIN jointable j USING (join_id)
    WHERE d.some_field = 'blah'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables one named Person , which contains columns ID and Name
I have two tables. One table contains words. Other table contains points. table words:
I have one mysql table that contains names of people (id, name) and another
What I have is two tables inside of a mysql database. One table contains
Here is my situation: I have one table that contains a list of drugs
I have one database table which contains 8 columns. One of the columns is
I have a TABLE elements with one COLUMN number, type SMALLINT that contains numbers
I have two databases: one contains the users: persons id name course the other
I have one table which contains events and dates, and another which contains the
I have a table in Oracle where one of the column contains UserIds which

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.