Re: [PHP] SQL Join query

2004-08-10 Thread Peter Brodersen
Hi, On Mon, 9 Aug 2004 18:12:42 +, in php.general you wrote: * Thus wrote Jonathan Haddad: The only problem there is when you group the LEFT JOIN pictures that have a count of 0 return a count of 1. Unfortunately there's no single query that I figured out when I did this same project

Re: [PHP] SQL Join query

2004-08-10 Thread Jason Wong
On Tuesday 10 August 2004 17:28, Peter Brodersen wrote: .. but this is rather an SQL-related question. That's what I pointed out last week when this thread started! Glad someone's paying attention :) -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems

Re: [PHP] SQL Join query

2004-08-09 Thread Jonathan Haddad
The only problem there is when you group the LEFT JOIN pictures that have a count of 0 return a count of 1. Unfortunately there's no single query that I figured out when I did this same project that would give accurate results. John Holmes wrote: Mattias Jönsson wrote: SELECT pics.*,

Re: [PHP] SQL Join query

2004-08-09 Thread Curt Zirzow
* Thus wrote Jonathan Haddad: The only problem there is when you group the LEFT JOIN pictures that have a count of 0 return a count of 1. Unfortunately there's no single query that I figured out when I did this same project that would give accurate results. SELECT pics.*,

Re: [PHP] SQL Join query

2004-08-09 Thread Mattias Thorslund
(Sorry about all the quoting but I thought it makes sense for clarity - Mattias) Curt Zirzow wrote: * Thus wrote Lenar Lhmus: Mattias Thorslund wrote: Though, (regardless of SQL database platform) in a case like this, it MAY be both more straightforward and efficient to use two separate

Re: [PHP] SQL Join query

2004-08-08 Thread Lenar Lõhmus
Mattias Thorslund wrote: Though, (regardless of SQL database platform) in a case like this, it MAY be both more straightforward and efficient to use two separate queries for the pictures and comments, given the one-to-many cardinality between them. The above statement causes redundant data

Re: [PHP] SQL Join query

2004-08-08 Thread Curt Zirzow
* Thus wrote Lenar Lhmus: Mattias Thorslund wrote: Though, (regardless of SQL database platform) in a case like this, it MAY be both more straightforward and efficient to use two separate queries for the pictures and comments, given the one-to-many cardinality between them. The above

[PHP] SQL Join query

2004-08-07 Thread Mattias Jönsson
I have a problem with my mysql query SELECT pics.*, pic_comments.*, count(*) AS num_comments FROM pics, pic_comments WHERE pics.category = 1 AND pics.id = pic_comments.pic_id GROUP BY pic_comments.pic_id; pics table: | id | submitter | time | date | category | pic_comments table: | pic_id |

Re: [PHP] SQL Join query

2004-08-07 Thread Jason Wong
On Saturday 07 August 2004 17:27, Mattias Jönsson wrote: I have a problem with my mysql query This is a PHP list. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development *

Re: [PHP] SQL Join query

2004-08-07 Thread raditha dissanayake
Mattias Jönsson wrote: I have a problem with my mysql query try postgres instead http://www.postgresql.org/ -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean

Re: [PHP] SQL Join query

2004-08-07 Thread Lenar Lõhmus
Raditha Dissanayake wrote: try postgres instead http://www.postgresql.org/ It's the most helpful comment I've seen for a long time. You know, it won't work in Postgre too probably. If you like Postgre - use it and don't force others to use it (for wrong reasons nevertheless). Everyone should

Re: [PHP] SQL Join query

2004-08-07 Thread John Holmes
Mattias Jönsson wrote: SELECT pics.*, pic_comments.*, count(*) AS num_comments FROM pics, pic_comments WHERE pics.category = 1 AND pics.id = pic_comments.pic_id GROUP BY pic_comments.pic_id; [snip] The problem is that i only get the the pictures that have comments, i want even the pictures

Re: [PHP] SQL Join query

2004-08-07 Thread Mattias Thorslund
Lenar Lõhmus wrote: Anyway, instead of writing this: SELECT pics.*, pic_comments.*, count(*) AS num_comments FROM pics, pic_comments WHERE pics.category = 1 AND pics.id = pic_comments.pic_id GROUP BY pic_comments.pic_id; Write this: SELECT pics.*, pic_comments.*, count(*) AS num_comments FROM

Re: [PHP] SQL Join query

2004-08-07 Thread raditha dissanayake
Lenar Lõhmus wrote: Raditha Dissanayake wrote: try postgres instead http://www.postgresql.org/ It's the most helpful comment I've seen for a long time. You are most welcome. -- Raditha Dissanayake.