PDA

View Full Version : Beginners table JOIN question


crighton
02-18-02, 12:41
Hi,

I'm trying to work out how to display data held in two seperate tables.

Table one (biografias) lists names of artists and authors. Table 2 (productos) lists names of artworks and books. The artist / author ID is shared across both tables, but the artist / author name and the artwork / book name are contained only in each relevant table.

What I've been trying to work out is how to join the two so that I can print out Book title by book author etc. but so far have been unable to find a tutorial simple enough for my low level. Can anyone point me in the right direction?

Thanks,

Gary Crighton

nigelrivett
02-18-02, 12:45
Table one (biografias) lists names of artists and authors. Table 2 (productos) lists names of artworks and books. The artist / author ID is shared across both tables, but the artist / author name and the artwork / book name are contained only in each relevant table.

What I've been trying to work out is how to join the two so that I can print out Book title by book author etc. but so far have been unable to find a tutorial simple enough for my low level. Can anyone point me in the right direction?


select Title = p.booktitle. Author = b.name
from biografias b
inner join productos p
on b.authorID = p.authorID
order by p.booktitle. b.name

crighton
02-20-02, 14:53
Hi,

For the idiots like me, the simple (and more legible solution) was as follows:

SELECT * FROM biografias, productos WHERE biografias.id = productos.id AND biografias.Tipo = 2 ORDER BY $order

Gary