Clueless on why these DO NOT reconcile. I really need query 1 results to be the same results as queries 2,3, and 4. Little help!
--- start query 1 ---
SELECT q1.* FROM
(SELECT apt.user_id, apt.client_id, c.last_name, c.first_name, MIN(apt.time_start) AS stime, FROM_UNIXTIME(MIN(apt.time_start),'%Y-%m-%d') AS ftime, (SELECT count(*) FROM tl_appt LEFT JOIN tl_rooms r on r.room_id = tl_appt.room_id WHERE client_id = apt.client_id AND r.location_id = '1' AND appt_status_id = '3' AND time_start < MIN(apt.time_start)) AS previous, (SELECT count(*) FROM tl_appt LEFT JOIN tl_rooms r on r.room_id = tl_appt.room_id WHERE client_id = apt.client_id AND r.location_id = '1' AND user_id = apt.user_id AND appt_status_id = '3' AND time_start > '1293858000') AS dr_all_ther_qty
FROM tl_appt apt LEFT JOIN tl_rooms r on r.room_id = apt.room_id LEFT JOIN tl_clients c on c.client_id = apt.client_id LEFT JOIN tl_users u on u.user_id = apt.user_id
WHERE apt.appt_id IS NOT NULL AND apt.time_start between '1293858000' and '1325393999' AND apt.appt_status_id = '3' AND apt.user_id = '506' and r.location_id = '1'
GROUP BY apt.user_id, apt.client_id ORDER BY u.last_name, u.first_name, c.last_name, c.first_name) as q1
WHERE q1.previous = 0
--- end query 1 ---
--- start query 2 --- SELECT count(*) AS dr_all_ther_qty FROM tl_appt LEFT JOIN tl_rooms r on r.room_id = tl_appt.room_id WHERE client_id = '254240' AND r.location_id = '1' AND user_id = '506' AND appt_status_id = '3' AND time_start > '1324927800' --- end query 2 ---
--- start query 3 --- SELECT count(*) AS dr_all_ther_qty FROM tl_appt LEFT JOIN tl_rooms r on r.room_id = tl_appt.room_id WHERE client_id = '253821' AND r.location_id = '1' AND user_id = '506' AND appt_status_id = '3' AND time_start > '1318617000' --- end query 3 ---
--- start query 4 --- SELECT count(*) AS dr_all_ther_qty FROM tl_appt LEFT JOIN tl_rooms r on r.room_id = tl_appt.room_id WHERE client_id = '254023' AND r.location_id = '1' AND user_id = '506' AND appt_status_id = '3' AND time_start > '1321903800' --- end query 4 ---
Don Wieland D W D a t a C o n c e p t s
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql
May 26
Baron Schwartz Re: Query weirdness...
May 26, 2012; 14:43
Baron Schwartz
Re: Query weirdness...
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!