[mysql] Query
UPDATE message_folder AS mf SET
mf.total=(SELECT sum(total) FROM message WHERE id='1' AND mf.folder = folder GROUP BY id),
mf.unread=(SELECT sum(unread) FROM message WHERE id='1' AND mf.folder = folder GROUP BY id)
WHERE mf.id = '1'
Хотелось бы не использовать два почти одинаковых select'a:
SELECT sum(total) FROM message WHERE id='1' AND mf.folder = folder GROUP BY id
и
SELECT sum(unread) FROM message WHERE id='1' AND mf.folder = folder GROUP BY id
а использовать один:
SELECT sum(unread), sum(total) FROM message WHERE id='1' AND mf.folder = folder GROUP BY id
Без хранимых процедур никак. Насколько мне помнится MySQL не поддерживает UPDATE FROM