Jump to content

problem with 'group by' aspect of sql statement!


debuitls

Recommended Posts

Hi all,

 

This is an extension of a thread below which ran yesterday!

 

But I dont expect anyone to read through the 27 entries so just gonna summarise here and see if anyone with a fresh pair of eyes today can make any suggestions!

 

Bascially I have two tables bid table and proposal table.

 

I'm trying to print to screen all the proposals made by a particular user!

 

The problem is that only those proposals that have bids made on them are printing to screen.

 

So for example if four proposals are made by a user, I want all four to be printed, however if only two of them have bids on them then only those will be printed.

 

I'm pretty sure its something to do with the group by statement as when I remove it, it seems to work fine, but I consequently lose the critical "count bids" info.

 

Anyway here's the code.

 

SELECT proposal . * , SYSDATE( ) , GROUP_CONCAT( bid.proposalid ) AS 'bids', TIME_FORMAT( TIMEDIFF( tomorrowtime, SYSDATE( ) ) , '%H hours, %i minutes' ) AS timeleft
FROM proposal
LEFT OUTER JOIN bid ON proposal.proposalid = bid.proposalid
WHERE NOW( ) < proposal.tomorrowtime
AND proposal.username = '$username'
GROUP BY bid.proposalid

 

If anyone can think of anything please let me know!

 

Been struggling with this for a while!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.