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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:46:29+00:00 2026-06-10T10:46:29+00:00

I have a DB with several tables that contain basic, static ID-to-name data. 2

  • 0

I have a DB with several tables that contain basic, static ID-to-name data. 2 Columns only in each of these reference tables.

I then have another table that will be receiving data input by users. Each instance of user input will have it’s own row with a timestamp, but the important columns here will contain either one, or several of the ID’s related to names in one of the other tables. For the ease of submitting and retrieving this information I opted to input it as text, in json format.

Everything was going great until I realized I’m going to need to Join the big table with the little tables to reference the names to the ID’s. I need to return the IDs in the results as well.

An example of what a few rows in this table might look like:

Column 1                            | Column 2                  | Timestamp
["715835199","91158582","90516801"] | ["11987","11987","22474"] | 2012-08-28 21:18:48
["715835199"]                       | ["0"]                     | 2012-08-28 21:22:48
["91158582","90516801"]             | ["11987"]                 | 2012-08-28 21:25:48

There WILL be repeats of the ID#’s input in this table, but not necessarily in the same groupings, hence why I put the ID to name pairings in a separate table.

Is it possible to do a WHERE name='any-of-these-json-values'? Am I best off doing a ghetto join in php after I query the main table to pull the IDs for the names I need to include? Or do I just need to redo the design of the data input table entirely?

  • 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-10T10:46:31+00:00Added an answer on June 10, 2026 at 10:46 am

    First of all:

    Never, ever put more than one information into one field, if you want to access them seperately. Never.

    That said, I think you will need to create a full N:M relation, which includes a join table: One row in your example table will need to be replaced by 1-N rows in the join table.

    A tricky join with string matching will perform acceptably only for a very small number of rows, and the WHERE name='any-of-these-json-values' is impossible in your construct: MySQL doesn’t “understand”, that this is a JSON array – it sees it as unstructured text. On a join table, this clause comes quite naturally as WHERE somecolumn IN (1234,5678,8012)

    Edit

    Assuming your Column 1 contains arrays of IDs in table1 and Column 2 carries arrays of IDs in table2 you would have to do something like

    CREATE TABLE t1t2join (
      t1id INT NOT NULL ,
      t2id INT NOT NULL ,
      `Timestamp` DATETIME NOT NULL ,
      PRIMARY KEY (t1id,t2id,`Timestamp`) , 
      KEY (t2id)
    )
    

    (you might want to sanity-check the keys)

    And on an insert do the following (in pseudo-code)

    Remember timestamp
    Cycle all permutations of (Column1,Column2) given by user
    Create row
    

    So for your third example row, the SQL would be:

    SELECT @now:=NOW();
    INSERT INTO t1t2join VALUES
      (91158582,11987,@now),
      (90516801,11987,@now);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several tables that contain several strings for fields. Some of these fields
I have several tables that contain multipolygons. I need to find points within these
I have several database tables that just contain a single column and very few
I have several tables that I am selecting data from. I am trying to
I have a data-upload function that load some data into several tables and processes
I have a table (several actually) that contain a lot of columns (maybe 100+).
I have ~300 text files that contain data on trackers, torrents and peers. Each
I have an SQLite3 database that contains several tables. All of these tables include
I have some MySQL databases that have several tables that contain (amongst others) some
I have several tables that I want to put side by side, however when

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.