Hãy thử
UPDATE t1 LEFT JOIN t2
ON t1.`group` = LEFT(t2.number, 3)
AND t1.number = 0 + RIGHT(t2.number, 5)
SET t1.used = 'NO'
WHERE t2.id IS NULL
và CHỌN
SELECT *
FROM t1 LEFT JOIN t2
ON t1.`group` = LEFT(t2.number, 3)
AND t1.number = 0 + RIGHT(t2.number, 5)
WHERE t2.id IS NULL
Đầu ra:
| ID | GROUP | NUMBER | USED |
------------------------------
| 3 | 110 | 3 | NO |
| 4 | 210 | 1 | NO |
| 6 | 210 | 3 | NO |