phpmysqlmedoo

Php Medoo select query


I need help with Medoo SQL query to select and display data of both columns on the below table but whenever I run my query only 1 row is returned is instead two, here's my query:

$database->select("chat_messages", "*", 
    [ "AND" => ["to_user_id" => 13, "from_user_id" => 14], "ORDER" => ["msg_time" => "DESC"] ]);

Is there something that I am missing to make the query display data for both from_user_id and to_user_id columns?

id from_user_id to_user_id message
1 13 14 Hello
2 14 13 Morning

The name of the table is chat_messages.


Solution

  • Use OR instead of AND

    Here is your updated query

    $database->select("chat_messages", "*", 
    [ "OR" => ["to_user_id" => 13, "from_user_id" => 14], "ORDER" => ["msg_time" => "DESC"]