0

I have a mysql row with 'date = 2013-05-02, type = 1' etc.

Then I run this query

SELECT date, type, status, rate 
FROM reservation 
WHERE  type = 1 
AND date BETWEEN 2013-05-01 AND 2013-05-08  
ORDER BY date asc 
LIMIT 0, 10

But this returns empty results. What is the query issue here?

3
  • 1
    you should add single quotes around your dates and to get specific answer please give some sample data. Commented May 19, 2013 at 17:08
  • 3
    The most important thing to note here, just so you understand why it wasn't working, is because you were literally searching between (2013 minus 05 minus 01) and (2013 minus 05 minus 08), the quotes transform your data into a string that can be transformed into a date object Commented May 19, 2013 at 17:12
  • Nice explain Bryan. I never think of that. Many many thanks for you. ' Here after I'll change my view as you explained. Thanks again.. Commented May 19, 2013 at 17:16

2 Answers 2

2

Put the dates in quotes ' in the mysql query.

SELECT date, type, status, rate 
FROM reservation 
WHERE  type = 1 
AND date BETWEEN '2013-05-01' AND '2013-05-08'
ORDER BY date ASC
LIMIT 0, 10 ;
Sign up to request clarification or add additional context in comments.

Comments

0

Try BETWEEN '2013-05-01' AND '2013-05-08'

1 Comment

Did you not see that this has already been submitted as an answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.