Another problem is that data is related, but it is difficult to query a table with n fields. the primary key id is then an array in the php code $ arr = array (& nbsp; array ('id' = & gt; '5', 'Num '= & gt; 100), & nbsp; array ('id' = & gt; '11 ', 'nu has another difficulty. The data has some connections, but it is not easy to do.
Or query
A table has n fields, where the primary key id
The php code then contains an array.
$ Arr = array (
Array ('id' => '5', 'num' => 100 ),
Array ('id' => '11', 'num' => 99 ),
Array ('id' => '3', 'num' => 98 ),
......
)
That is to say, the $ arr array is arranged in ascending order of num, and the id order is as follows,
Then it is required that the database query set should look up the corresponding set according to the order of the IDs. how can this problem be solved ,,
It seems a little undisciplined, but it seems a little connected.
------ Solution --------------------
Is the id displayed in the array ??
If yes: the id is an array, and then the SQL id in (implode ())
------ Solution --------------------
Import arrays to temporary tables
Associate query with the source table, join key id, and sort key temporary table. num
------ Solution --------------------
If an array $ arr = (, 1); and a table exist, you can sort the table by $ arr using the following SQL statement:
SQL code
SELECT t. * FROM 'table' t, (SELECT 3 AS id union select 2 union select 1) AS arr WHERE t. id = arr. id
------ Solution --------------------
Order by can be sorted based on the values you provide, but the efficiency of the sort image is not the same.
------ Solution --------------------
It is best to leave this to php.