Specific situation: One user table and the other is a user level table. I query (select) the information of the user table and want to sort it according to the power field of the user level table. What I wrote myself is to query the records one by one through a for loop. It feels unscientific to write it into a two-dimensional array. I can check the database as many times as there are pieces of data. Is there a better way to write multi-table queries? Related?
In other words, query the information of people with IDs 3,5,2 and sort them by 3,5,2
Is there a useful framework? If you use the framework, the multi-table related query in it is simpler to write. Now write a native sql statement. Because I don’t understand the second half of your request, I will write it according to the power field sorting of the user level table:
sql = "SELECT u.id,u.name,m.power FROM user table as u INNER JOIN user level table as m ON u.id = m.uid ORDER BY m.power";
What to check specifically The fields are based on their own needs. u.id represents the id in the user table, and m.uid is the user id field attribute stored in the user level table