MySQL Date comparison problem
The table Kucun now has datavalue (varchar, which is the 2012-01-01 format date) and the price (float 11,2) field
Now I want to get the data from 2012-07-10 to 2012-08-10.
1,
SELECT * from ' Kucun ' where datavalue between ' Unix_timestamp (2012-07-10) ' and ' Unix_timestamp (2012-08-10) '
Result is empty
2,
SELECT * from ' kucun ' WHERE datavalue between ' 2012-07-10 ' and ' 2012-08-10 '
The result is correct, get the data I want to find.
3,
SELECT * from ' Kucun ' where Unix_timestamp (datavalue) >unix_timestamp (2012-07-10) and Unix_timestamp (DataValue)
<>
Result is empty
Why are 1 and 3 empty? 2 is it normal to write like this? Xxxx-xx-xx such a format date can be compared?
------Solution--------------------
1.
SELECT * from ' Kucun ' where datavalue between ' Unix_timestamp (2012-07-10) ' and ' Unix_timestamp (2012-08-10) '
To delete the extra quotes
3.
SELECT * from ' Kucun ' where Unix_timestamp (datavalue) >unix_timestamp (' 2012-07-10 ') and Unix_timestamp (DataValue)
<>
To fill in the necessary quotation marks
------Solution--------------------
The string parameter of the Unix_timestamp () function is quoted, so try:
SQL Code
SELECT * from ' Kucun ' where Unix_timestamp (datavalue) >unix_timestamp (' 2012-07-10 ') and Unix_timestamp (DataValue)
<>