복붙노트

[SQL] `alias` ...`alias`.`column` ... 왜 구문 오류 AS table``에서 삭제?

SQL

`alias` ...`alias`.`column` ... 왜 구문 오류 AS table``에서 삭제?

나는 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의 특정인가요?

해결법

  1. ==============================

    1.이 같은 SQL을 사용할 수 있습니다 :

    이 같은 SQL을 사용할 수 있습니다 :

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

    2.@Matus 및 @CeesTimmerman은 MSSQL에 대해 말을 너무 MySQL은 5.1.73에서 작동 :

    @Matus 및 @CeesTimmerman은 MSSQL에 대해 말을 너무 MySQL은 5.1.73에서 작동 :

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

    3.당신은 MySQL의와 DELETE 절에 AS를 사용할 수 없습니다 :

    당신은 MySQL의와 DELETE 절에 AS를 사용할 수 없습니다 :

    DELETE FROM `contact_hostcommands_relation` WHERE (`chr_id` = 999999) LIMIT 1 
    
  4. from https://stackoverflow.com/questions/10484532/delete-from-table-as-alias-where-alias-column-why-syntax-error by cc-by-sa and MIT license