Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table lookup help - newbie

Status
Not open for further replies.

rrsub

MIS
Oct 23, 2002
536
US
I usually like to dig this myself but MySQL is one of those where there are many ways to do the same thing. If no one replies, that's fine. This isn't life or death yet.

I have 2 tables.

Table 1 has 3 fields, index, name, server
Table 2 has 3 fields, index, server, ip_addr

The values of table 1 are as follows (and this is an example, the data is pretty long):
index name server
1 domain 2

the values of table 2 are:
index server ip_addr
1 ns_domain1 x.x.x.x
2 ns_domain2 x.x.x.x

When I list the results of table_1, I would like the SERVER field to display the SERVER value from table 2 based upon the index value
where SERVER from table_1 = index from table_2

I though this path would be the answer but far from it

mysql_query( "SELECT server FROM table_2 WHERE index = $server_table_1 ", $link)


{my variable are correct on the real PHP script, these are examples}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top