I have a registration application for registering 6 courses. The program will check the repeated register users first. Those users that needed to be checked comes from last year. If users registered for one course, they cannot register for any other courses.
---firstroundregisted table structure---
id|englishname |idcard |
1 |CHAN SIU MING|A1234 |
2 |TAK HO KANG |Z4123 |
---Contain >5000 last year registered users records for the 6 courses---
The sql in PHP as below.
SELECT * FROM firstroundregisted
WHERE englishname='".$_POST['studentname']."'
AND idcard='".$_POST['idcard']."'
LIMIT 1;
Is this sql the fastest way to find out if the user registered or not?
Others:
I asked a question here : How to increase Max_used_connections? Some gentlemen suggested me to optimizing the sql query so I start a new question to focus on optimizing. Thank you all for your help.
englishname
column? What column identifies the course? – Akina Nov 13 '20 at 4:50INDEX(englishname, idcard)
? – Rick James Nov 13 '20 at 5:04englishname
ANDidcard
. Don't have INDEX. Thanks. – Muffin Nov 13 '20 at 8:04