mysql - PHP - Fetching only one row if there is more results for two conditions -


this question has answer here:

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:

enter image description here

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

Popular posts from this blog

Listboxes in c# -

Excel Duty List -

Multilayer CSV to filtered excel -