MySQL Concatenate and Compare
Ever come across a database table where the date and time where two separate fields? How do you run comparisons against them? What if you need to get all records between Monday at 5pm and Tuesday at 2:30am?
You have to concatenate the fields before doing comparisons. In MySQL I found that this is extremely easy:
SQL:
-
SELECT * FROM `table` WHERE CONCAT(`date`,' ',`time`) BETWEEN ‘2006-10-02 17:00:00′ AND ‘2006-10-03 02:30:00′
Home | MySQL | MySQL Concatenate and Compare
You’re currently reading “ MySQL Concatenate and Compare ,” an entry on BRADINO
- Published:
- 3.24.07 / 9am
- Category:
- MySQL












