Hi all,
I'm aware that this post is borderline MySQL, but the solution may be more
PHP-oriented, so I'm asking here first.
I have 4 related tables:
partner (id,name,url,desc)
category (id,name)
service (id,categoryid,name)
pid_to_sid (pid,sid)
To point out the obvious, a partner provides one
mailto:[EMAIL PROTECTED]
- Original Message -
From: Justin French [EMAIL PROTECTED]
To: php [EMAIL PROTECTED]
Sent: Thursday, January 23, 2003 11:26 AM
Subject: [PHP] nested queries/loops
Hi all,
I'm aware that this post is borderline MySQL, but the solution may be more
PHP-oriented
For me it seems it can be done with one mysql query:
SELECT * FROM partner p LEFT JOIN pid_to_sid p2s ON p.id=p2s.pid LEFT
JOIN service s ON p2s.sid=s.id LEFT JOIN category c ON s.categoryid=c.id
WHERE $your_conditions ORDER BY p.name, c.name, s.name
The important part is ORDER BY clause, so
Thanks Marek, That put me right on track :)
Justin
on 23/01/03 11:24 PM, Marek Kilimajer ([EMAIL PROTECTED]) wrote:
SELECT * FROM partner p LEFT JOIN pid_to_sid p2s ON p.id=p2s.pid LEFT
JOIN service s ON p2s.sid=s.id LEFT JOIN category c ON s.categoryid=c.id
WHERE $your_conditions ORDER BY
4 matches
Mail list logo