MySQL有两个数据库查询:
1)SELECT id, username, subject, message, created FROM messages WHERE new = 1 AND view = '$ auth_user'
2)SELECT DATE_FORMAT (created, '% d% M% Y% T') FROM messages
您能告诉我如何将它们合并到一个SQL查询中吗?
答案 0 :(得分:2)
你去了:
SELECT id, username, subject, message, created, DATE_FORMAT (created, '% d% M% Y% T') FROM messages WHERE new = 1 AND view = '$auth_user'
但请记住,您的第二个查询会从您的表中返回所有消息日期。您的第一个查询会返回包含属性new = 1
和view = $auth_user
的所有邮件。
编辑:
SELECT id, username, subject, message, DATE_FORMAT (created, '% d% M% Y% T') AS created FROM messages WHERE new = 1 AND view = '$auth_user'
答案 1 :(得分:1)
SELECT id, username, subject, message, created, DATE_FORMAT (created, '% d% M% Y% T')
FROM messages
WHERE new = 1 AND view = '$auth_user'
现在第二个查询依赖于Where子句