mysql - PHP - Fetching only one row if there is more results for two conditions -
this question has answer here:
- top , order sql error 3 answers
i display latest 1 of rows match conditions. conversation listing page display latest message user or his/her partner, , display next conversation's latest message between user , partner, , on...
i have database:
and code fetch data:
$db = new pdo("mysql:host=localhost; dbname=dbname", 'root', ''); $stmt4 = $db->prepare(" select * messages messages.from_id=7 or messages.to_id=7 order msg_id desc "); $stmt4->execute();
is possible somehow?
you need add limit 1 query.
select * messages messages.from_id=7 or messages.to_id=7 order msg_id desc limit 1
Comments
Post a Comment