i got 2 mysql queries, that retrieve the same data?, what one do you think is better to use and why? taking into account standards, and better code etc. sorry if this is a stupid question, but im a curious cat! so here goes:
QUERY 1:
SELECT *
FROM
((
SELECT u.username, u.picture, m.id, m.user_note, m.reply_id, m.reply_name, m.dt
FROM relationships r
JOIN notes m ON m.user_id = r.leader
JOIN user u ON r.leader = u.user_id
WHERE r.listener ='2'
)
UNION ALL
(
SELECT u.username, u.picture, m.id, m.user_note, m.reply_id, m.reply_name, m.dt
FROM notes m
JOIN user u ON m.user_id = u.user_id
WHERE u.user_id ='2'
)) d
WHERE d.dt < '2010-09-20_131830'
ORDER BY d.dt DESC
QUERY 2:
SELECT u.username, u.picture, m.id, m.user_note, m.reply_id, m.reply_name, m.dt
FROM notes m
INNER JOIN user u
ON m.user_id = u.user_id
WHERE (m.user_id = '2'
OR m.user_id IN (
SELECT r.leader
FROM relationships r
WHERE r.listener ='2'))
AND dt < '2010-09-20_131830'
ORDER BY dt DESC