我有这样的查询:
SELECT * FROM messages
WHERE recipients LIKE '%0688427893%'
AND 'dateadded' > '2015-05-13 12:52:57'
ORDER BY dateadded ASC
这应该只选择在 2015-05-13 12:52:57 之后添加的消息,但不是这样做,而是选择所有消息。我在这里做错了什么?
答案 0 :(得分:2)
SELECT * FROM messages
WHERE recipients LIKE '%0688427893%'
AND dateadded > '2015-05-13 12:52:57'
ORDER BY dateadded ASC
如果要在MySQL中转义列名,请使用反引号
`dateadded`
使用引号将其转换为普通字符串
'dateadded'