Home > database >  Why SQL error
Why SQL error

Time:09-20

Select * from xty_orders where a ORDER_STATUS='has been proofread and PATIENT_ID in
(select PATIENT_ID from xty_orders b where ORDER_STATUS='stopped' GROUP BY PATIENT_ID HAVING count (PATIENT_ID) & gt; 1)

The retrieval is normal, I am an error to delete, why???????
Delete from xty_orders where a ORDER_STATUS='has been proofread and PATIENT_ID in
(select PATIENT_ID from xty_orders b where ORDER_STATUS='stopped' GROUP BY PATIENT_ID HAVING count (PATIENT_ID) & gt; 1)

1064 - You have an error in your SQL syntax; Check the manual that corresponds to your MySQL server version for the right syntax to use near 'where a ORDER_STATUS=' has been proofread 'and PATIENT_ID in
(select PATIENT_ID from xt 'at line 1

CodePudding user response:

https://blog.csdn.net/chs_jdmdr/article/details/46708917

CodePudding user response:

Delete from xty_orders where a ORDER_STATUS='has been proofread and PATIENT_ID in
(SELECT PATIENT_ID FROM (SELECT PATIENT_ID FROM xty_orders b where ORDER_STATUS='stopped' GROUP BY PATIENT_ID HAVING count (PATIENT_ID) & gt; 1))

CodePudding user response:

DELETE a characteristic of MYSQL, for example:
The DELETE TABLE_A T1 WHERE T1. ID IN (SELECT T2. ID FROM TABLE_A T2);
This direct link the same table delete will be an error, then set a good, for example:
The DELETE TABLE_A T1 WHERE T1. ID IN (SELECT ID FROM (SELECT T2. ID FROM TABLE_A T2));
  • Related