programing

'table'에서 'alias'로 삭제...여기서 'alias'.'열'...왜 구문 오류입니까?

minimums 2023. 11. 4. 10:31
반응형

'table'에서 'alias'로 삭제...여기서 'alias'.'열'...왜 구문 오류입니까?

MySQL로 해봤습니다.

DELETE FROM `contact_hostcommands_relation` AS `ContactHostCommand` WHERE (`ContactHostCommand`.`chr_id` = 999999) LIMIT 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 (`ContactHostCommand`.`chr_id` = 999999) LIMIT 1' at line 1

참고: 이 쿼리는 자동으로 생성되며 조건은 테이블 별칭을 기반으로 합니다.

왜 이런 오류가 발생합니까?

where 절에서 테이블 별칭을 사용할 수 있는 방법이 있습니까?

MySQL이 특정한 건가요?

MSSQL에 대해 @Matus와 @CeesTimmerman이 말한 내용은 MySQL 5.1.73에서도 작동합니다.

delete <alias> from <table> <alias> where <alias>.<field>...

SQL은 다음과 같이 사용할 수 있습니다.

DELETE FROM ContactHostCommand 
USING `contact_hostcommands_relation` AS ContactHostCommand 
WHERE (ContactHostCommand.`chr_id` = 999999) 
LIMIT 1

사용할수없습니다AS일순간에DELETEMySQL이 포함된 절:

DELETE FROM `contact_hostcommands_relation` WHERE (`chr_id` = 999999) LIMIT 1 

MySQL에서 Alias를 사용하려면 다음을 사용해 보십시오.

DELETE <alias_name> FROM <alias_table> <alias_name> WHERE <alias_name>.nameofcolumn LIKE '%XXXXX%'

언급URL : https://stackoverflow.com/questions/10484532/delete-from-table-as-alias-where-alias-column-why-syntax-error

반응형