wowzuzz
wowzuzz

Reputation: 1388

Looping through ID to display output from other table

I have an id in table x representing a state in another table.

For instance.

Table x has a state id of 1 and that id of 1 in table z represents a state.

How would I loop through this in php and mysql to display the value of that id from table z?

Upvotes: 0

Views: 60

Answers (2)

NappingRabbit
NappingRabbit

Reputation: 1918

same solution, simplier notation is

select z.id
from tablex x,
     tablez z
where x.id = z.id

Upvotes: 0

wesside
wesside

Reputation: 5740

An INNER JOIN to make sure it connects.

SELECT z.id FROM x INNER JOIN z ON (x.id = z.x_id)

Upvotes: 1

Related Questions