Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 18: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

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