Another difficulty is that data is related, but it is difficult to solve the problem.

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.