If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL 4.0.24 ver - GROUP BY problem?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-07, 17:27
infernalbyte infernalbyte is offline
Registered User
 
Join Date: Sep 2007
Posts: 1
MySQL 4.0.24 ver - GROUP BY problem?

HI

I am using this old version because of compatiobility with my old PHP ver 4.4.0 on which i have developed many web applications. Now i have one problem and i need to solve very quick, this is my query:

SELECT DISTINCT id,rut_id,usr_id,COUNT(city_id) AS sitis,COUNT(acc_id) AS accomo,SUM(days) AS dejs ,SUM(price*days) AS prajs,agree FROM route GROUP BY rut_id HAVING usr_id=$_SESSION[id] AND agree="N" ORDER BY rut_id

This should return all notcompletted tourist routes with calculated price of border and so on.But what is the problem, problem is when one user have many route registered, for some new user who have registered one or two routes this query doesnt return any result, return empty result set.
OK, decide to split this query in 2 separete like this:

SELECT DISTINCT rut_id,usr_id FROM route WHERE usr_id=$_SESSION[id] AND agree='N' ORDER BY rut_id ASC

where i fill some array with all not completted route id,

and

SELECT id,rut_id,usr_id,COUNT(city_id) AS sitis,COUNT(acc_id) AS accomo,SUM(days) AS dejs ,SUM(price*days) AS prajs,agree FROM route GROUP BY rut_id HAVING rut_id=$notcomp[$i] AND usr_id=$_SESSION[id] ORDER BY rut_id
which is inside for loop.

Now, the problem still exist, any suggestions?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On