user2027275
user2027275

Reputation: 45

How do I display data from table2 via table1 using mysql?

I have two tables, directory, and pictures. Both directory and pictures contain an ID number in column 1. I want row 1 (ID 1) of directory to pull information of pictures. I want it to be versatile, i.e. if I pull ID 2 from directory it will show ID 2 from pictures.

I want directory.ID to pull Pictures.photo based on ID. Maybe this makes more sense...

Upvotes: 0

Views: 62

Answers (1)

Ivo
Ivo

Reputation: 450

For this purpose you should use a JOIN.

select * 
from directory d
JOIN pictures p ON d.ID = p.ID

Upvotes: 2

Related Questions