-1

Well I have a weird problem with MySQL.

I have a table like this :

# table_name #
==============
ID | DATE | RESULT_DATE

When I do

SELECT * FROM table_name

the output show me the table_name.RESULT_DATE as NULL or if there is a date, it show me the date.

BUT, when I do something like this :

SELECT * FROM table_name WHERE DATE BETWEEN '2017-05-03' AND '2017-05-08'

the output show me the table_name.RESULT_DATE as 00-00-0000 for ALL the elements, if they were NULL or if they had a Date element...

Why is this happening?

Thanks

Simon Trichereau
  • 721
  • 11
  • 19
  • 2017 minus 5 minus 3 equals 2009 – Strawberry May 23 '17 at 23:24
  • Well no, this is not the same question ... In the question you linked it's talking about which quotes should be use, in my question I just want to know why I obtain that result and it's not a problem of Quotes, I tried every quotes possible and get the same result! – Simon Trichereau May 24 '17 at 13:47
  • Well I guess you asked the wrong question then. I'll reopen... – Strawberry May 24 '17 at 14:03
  • See https://meta.stackoverflow.com/questions/333952/why-should-i-provide-an-mcve-for-what-seems-to-me-to-be-a-very-simple-sql-query – Strawberry May 24 '17 at 14:03
  • Hmmm I read the link, but I didn't find my answer... Sorry If I asked the wrong question, to make it easier, when I select without WHERE I have my **RESULT_DATE** column with _NULL_ or _dates_, but when I Select with a WHERE statement, my **RESULT_DATE** column is full of _00-00-0000_ date (and this is also strange because it doesn't respect the date format `YYYY-MM-DD`)... It's the first time I get something like this... – Simon Trichereau May 24 '17 at 14:24
  • I guess you didn't really read the link. Even if I say so myself, the accepted answer is entirely self-explanatory. – Strawberry May 24 '17 at 14:32

1 Answers1

2

You forgot the quotes around the dates

SELECT * FROM table_name WHERE DATE BETWEEN '2017-05-03' AND '2017-05-08'
                      here------------------^----------^-----^----------^
juergen d
  • 201,996
  • 37
  • 293
  • 362