Can anyone tell me what is the wrong with the query? It's not following the date condition. It's returning all the data and I want data less than the mentioned date.
SELECT `messages`.*, `user`.`firstname`, `user`.`lastname`, `user`.`organisation_name`, `user`.`type`, `user_info`.`profile_picture`, `user_info`.`logo`, `user`.`email`
FROM (`messages`) JOIN
`user`
ON `user`.`user_id` = `messages`.`from_id` JOIN
`user_info`
ON `user_info`.`uid` = `messages`.`from_id`
WHERE `messages`.`from_id` = '4' AND
`messages`.`to_id` = '24572' AND
`messages`.`time_sent` <= '2016-06-23 12:41:47' OR
`messages`.`from_id` = '24572' AND
`messages`.`to_id` = '4' AND
`messages`.`time_sent` <= '2016-06-23 12:41:47'
ORDER BY `msg_id` DESC