During the project development process, you need to query the transactions within a certain period of time. Therefore, it is necessary to add date and time elements to the sql query statement. How to implement the sql statement?
SELECT * FROM lmapp.lm_bill where tx_time Between '2015-12-20' And '2015-12-31' ;
Careful study can still reveal some detailed issues.
SQLStatement1
## SELECT * FROM lmapp.lm_bill where merch_uid='S18853883587' AND tx_time Between '2015-09-17' AND '2015-10-27 24:00:0';
Query results1
## SQL
Statement2## SELECT * FROM lmapp.lm_bill where merch_uid='S18853883587' AND tx_time Between '2015-09-17
0:00:0' AND '2015-10-27 24:00:0'; Query results
2
## SQLStatement
3## SELECT * FROM lmapp.lm_bill where merch_uid='S18853883587' AND tx_time Between '2015-09-17' AND '2015 -10-27';
Query results3
Through comparison, it can be clearly found that the query results corresponding to the above three SQL statements are different. If you want to only use date as the query condition and ignore time, you need to further process the sql statement.
Data storage situation in the database:It can be seen that
SQLstatement
1is a query statement that satisfies the conditions. The above is the content of mysql advanced (nineteen) SQL statements on how to accurately find data in a certain time period. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!