user3341505
user3341505

Reputation:

Mysql date compare error LIMIT 0,30

I want to compare my date with data in mysql db, but i have an error " #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE '2014-06-09' >= date_start AND '2014-06-11' <= date_end) LIMIT 0, 30' at line 4".

SELECT name
FROM seminars
WHERE allowed_users LIKE '%1%'
AND (WHERE '2014-06-09' >= date_start AND '2014-06-11' <= date_end)

Upvotes: 0

Views: 715

Answers (2)

Krishna
Krishna

Reputation: 438

You have used "where" keyword twice which is creatin problem. Also suggest you to use date function in case you are storing datetime in your start and end date column, to ensure no records are skipped.

SELECT name
FROM seminars
WHERE allowed_users LIKE '%1%'
AND ( '2014-06-09' >= date(date_start) AND '2014-06-11' <= date(date_end))

Upvotes: 1

Vishnu
Vishnu

Reputation: 12313

SELECT name
FROM seminars
WHERE allowed_users LIKE '%1%'
AND '2014-06-09' >= date_start AND '2014-06-11' <= date_end

Upvotes: 0

Related Questions