Jump to content

get data from different table based on another table


peranha

Recommended Posts

I have 2 tables that I need to get data from.

 

table 1

id, city, city_perm_sup, city_temp_sup, city_perm_dem, city_temp_dem

1  test           1                  5                     15                      2

1  test2         5                   8                      9                      1

...

 

table 2

id,   supp

1      Autos

2      Timber

...

 

I need to select the supp field from table 2 where its id is equal to the fields in table 1 and echo them out.  I dont know how to do that though.  Do I need to add another table?  More than 1 query, I can think of doing it with 5 queries?

 

SELECT S.supp FROM " . $pre . "city C INNER JOIN " . $pre . "supp S ON ??? = S.id WHERE ???;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.