-2

I have query like this:

SELECT * FROM messages
WHERE recipients LIKE '%0688427893%'
AND 'dateadded' > '2015-05-13 12:52:57'
ORDER BY dateadded ASC

This should select only messages that are added after 2015-05-13 12:52:57, but instead of doing that, it is selecting all messages. What am I doing wrong here?

Sasha
  • 8,521
  • 23
  • 91
  • 174

1 Answers1

2
SELECT * FROM messages
WHERE recipients LIKE '%0688427893%'
AND dateadded > '2015-05-13 12:52:57'
ORDER BY dateadded ASC

If you want to escape a column name in MySQL then use backticks

`dateadded`

Using quotes turns it into a normal string

'dateadded'
juergen d
  • 201,996
  • 37
  • 293
  • 362