SELECT q.q_id, q.user_id, IF (e.firstname IS NULL , q.name, e.firstname) AS name, t.town, e.type, e.trading_name, e.posts
FROM qa_uk q
LEFT JOIN ayn_experts e ON e.unique_id = q.user_id AND e.active = 1
LEFT JOIN ayn_towns t ON t.id = q.town_id
WHERE q.active =1 AND t.town IS NOT NULL
GROUP BY q.user_id, q.name, q.town_id
ORDER BY q.datetime DESC
This query runs, however the field that comes back from the aggregate functions for the q fields is the first field in the database matching all others, how do i make it the last?
--BB
FROM qa_uk q
LEFT JOIN ayn_experts e ON e.unique_id = q.user_id AND e.active = 1
LEFT JOIN ayn_towns t ON t.id = q.town_id
WHERE q.active =1 AND t.town IS NOT NULL
GROUP BY q.user_id, q.name, q.town_id
ORDER BY q.datetime DESC
This query runs, however the field that comes back from the aggregate functions for the q fields is the first field in the database matching all others, how do i make it the last?
--BB