I’m learning more about SQL and have found it helpful already in solving a problem I was going to have to post-fix in PHP, now I’ve found mysql can do it on retrival.
The query I have is this.
SELECT *
FROM `messages`
LEFT JOIN `users` ON messages.message_by = users.id
WHERE job_id = '135'
ORDER BY message_date DESC
But I want to do this now,
SELECT DATE_ADD(`message_date`, INTERVAL 6 HOUR) AS `message_date`, *
FROM `messages`
LEFT JOIN `users` ON messages.message_by = users.id
WHERE job_id = '135'
ORDER BY message_date DESC
Where the date_add part fixes a time zone difference problem, but as I’ve put that in the select part of the statement I now don’t know how to use the , * (and then everything else) it’s not working. I don’t want to have to list every field I’m after retrieving just because I’ve added this date fix…
What is a way around it? Thanks.
Just prepend the name of the table and it should work
Also, are you SURE you need to select all of the fields? You can improve speed by only selecting the columns you need.