Currently I'm having,
Table1:
ID | DEVICEID | STATUS |
--------------------------------
1 | SN001 | ENROLL |
2 | SN002 | ENROLL |
Table2:
ID | DEVICEID | STATUS |
--------------------------------
1 | SN001 | ENROLL |
2 | SN002 | ENROLL |
3 | SN003 | ENROLL |
4 | SN004 | ENROLL |
There is a form to fill up in order to insert new DEVICEID and STATUS in Table1 using AJAX POST to PHP. Before update the SQL, how do I create a condition where Table1 only can be updated if only there is same DEVICEID filled up in form with DEVICEID in Table2 else it will return error and will not update the Table1.
Here's what I have:
"SELECT deviceid
FROM table1
INNER JOIN table2 ON table1.deviceid=table2.deviceid
INSERT INTO table1(deviceId,status)
VALUES('$deviceid', '$status')
WHERE deviceid = deviceid"; <--- Not sure what I'm doing here, trying to compare