A general single sql query

前端 未结 3 1498
醉话见心
醉话见心 2021-01-27 12:07

I have a table like this:

id | roll_no | name
---------------------
 1 |   111   | Naveed
 2 |   222   | Adil
 3 |   333   | Ali 

If I

3条回答
  •  遥遥无期
    2021-01-27 12:21

    Complete solution with the help of accepted answer.

    $tableName = "test"; 
    $fields = array( "id" , "roll_no" );
    $values = array( "1,111", "2,222" );
    
    $fieldsStr = implode(',', $fields);
    $valuesStr = implode("','", $values);
    
    // Get all records from remote table
    $sql = "SELECT * FROM $tableName WHERE concat_ws(',', $fieldsStr ) NOT IN ( '$valuesStr' )";
    

提交回复
热议问题