I've got two tables, a log table, and a summary table. I want to take the output of:

SELECT COUNT(id) as logins, COUNT(DISTINCT(user)) as users FROM table GROUP BY domain;

... and increment another table with the values;

CREATE TABLE log_summary (
domain varchar(50) primary key,
logins int unsigned,
users int unsigned
);

... and I want to update 'users' to be the higher of the two values ... `MAX(users, log_summary.users)` ... and increment logins. This is currently 3 queries and a bit of Python code; any way to shorten it? I know I could do the 'users' value by doing a `REPLACE INTO ... SELECT ...` but it doesn't do the logins incrementing for me, and it seems that doing two queries (one to increment, if possible, one to replace) would be a waste of processing, given that I don't have a query cache (I'm running 3.23.53).

--
Michael T. Babcock
C.T.O., FibreSpeed Ltd.
http://www.fibrespeed.net/~mbabcock



---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to