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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:19:07+00:00 2026-05-23T18:19:07+00:00

At first I thought this may work as a join but I’m not sure

  • 0

At first I thought this may work as a join but I’m not sure if this is really a union command or if even possible. Below is an example of the two tables and each has about 20 more columns of various different data.

Table 1

>     id    assembly    user1    user2    containerID    productID    packageID
      1     line2       Billy    John     3794           4892         4589
      2     line4       John     Doug     7794           6201         7864

Table 2

>     item_id    name    width    height    weight    flag1    flag2
      3794       Box     10       10        10        0        1
      4892       Lamp    4        6         2         1        1
      7864       BigBox  200      200       300       4        5      

What I am trying to do is show all of Table 1 but replace the containerID, productID, and packageID with their name from Table 2 using the matching item_id. Tried doing this outside of mysql with foreach but with Table 2 having 30k rows it lags up “just a bit” when trying to display the hundreds of rows from Table 1 and replacing each id with its name equivalent.

  • 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-05-23T18:19:08+00:00Added an answer on May 23, 2026 at 6:19 pm

    To see all the table_1 records, use:

       SELECT t1.id, t1.assembly, t1.user1, t1.user2, 
              t2c.name, t2pr.name, t2pk.name
         FROM TABLE_1 t1
    LEFT JOIN TABLE_2 t2c ON t2c.item_id = t1.containerid
    LEFT JOIN TABLE_2 t2pr ON t2pr.item_id = t1.productid
    LEFT JOIN TABLE_2 t2pk ON t2pk.item_id = t1.packageid
    

    You can change those to INNER JOINs, but any row that doesn’t match all three will not be in the resultset.

    My query uses table aliases, because you have to join to the appropriate TABLE_2 column for each name you want to look up.

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

Sidebar

Related Questions

Not sure how to work this but I found a way that works although
Okay at first I thought this would be pretty straightforward. But I can't think
This may sound trivial, but I'm pretty sure this question hasn't been asked, or
here's the main code at first I thought is was the message box but
And I'm not meaning Bits Per Minute, but Business Process Management. At first though
This is my first attempt to use WCF so there may be something fundamentally
When I first saw javax.swing.tree.TreeModel , I thought it's quite a lot of work
This is my first time on StackOverflow though I read Coding Horror quite often.
does the following integer arithmetic property hold? (m/n)/l == m/(n*l) At first I thought
Ok first of all, the unicorn avatars are hilarious. Seriously, I thought my account

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.