PHP automatically arranges the test seat number, how to write a random write statement
Source: Internet
Author: User
PHP automatically arranges the test seat number, how to write a random write statement?
This is an examination of the random seating procedures, Cityid is the city ID, if from the same city, that is, the city ID of the same 3-bit location to arrange seats, to prevent cheating.
The number of students is uncertain, but there are already *
How can you achieve the following effect (if the city ID is the same, separate the 3-bit to update the UserID and Cityid to the seating chart, you can achieve the same city without learning to be together on the line), to find
Body SQL statement, thank you!
Zwid kcid userid Cityid
1 001 003 4501
2 001 002 4502
3 001 009 4512
4 001 007 4504
5 001 001 4501
6 001 006 4502
7 001 008 4505
8 001 004 4503
9 001 005 4502
. .
. .
. .
------to solve the idea----------------------
This is an algorithmic problem.
You can iterate through the student table and insert the traversed * into the seating chart. Determine whether the first three seats have the same city before each insert before inserting the seat data; yes, no insert; no, insert.
Keep looping until the student table is all plugged in. To exclude the * that has been inserted during the loop.
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.