query with 3(4) tables.

Hi,

I’m struggling with 3 tables, i want to make a query en have to make two joins (if possible).

[table]
[tr][td] (table 1) [/td][td] [/td][td] (table 2) [/td][td] [/td][td] (table 3) [/td][td] [/td][td] (table 4)[/td][/tr]
[tr][td] Cat (table name) [/td][td] [/td][td] Cat_Prod (table name) [/td][td] [/td][td] Prod (table name) [/td][td] [/td][td] Fab (table name) [/td][/tr]
[tr][td] catagory [/td][td] [/td][td] id [/td][td]=== [/td][td] id [/td][td] [/td][td] name [/td][/tr]
[tr][td] category_id [/td][td] === [/td][td] category_id [/td][td] [/td][td] manufacturer_id [/td][td] === [/td][td] manufacturer_id[/td][/tr]
[/table]

I have to query on category_id and need the fields category, some Prod fields, and ’ name ’ from Fab.

How do I get this?!?!!? :o

[php] $SQL_statement = "SELECT * FROM Cat_Prod JOIN Prod on Cat_Prod.product_id = Prod.id WHERE category_id = ‘$id’ AND Prod.status >0 ORDER BY id ASC ";
[/php]
When I use this I can not diplay Fab.name or Cat.category?

The $id is coming from the url ($category_id=$_GET[‘id’] ; )

Is there someone who can help?

Thanks Rob.

This topic was marked solved, without any replies. Rob, did you solve it yourself? Or do you still need help?

Hello ErnieAlex,

After a good night rest and a bit of google I found out it isn’t so hard to do the trick.

First I tried UNION, this I don’t understand, :-[
but a few JOINS did trick.
Simpel and easy, thanks for the help (again) on this great forum.

Rob

Glad you solved it. Always a nice warm fuzzy feeling to solve a programming puzzle!

CYA in the bitstream…

Sponsor our Newsletter | Privacy Policy | Terms of Service