반응형
'INSERT INTO' 근처의 구문 오류로 인해 실패하는 SQL 쿼리에서 오류가 어디에 있는지 이해하는 방법
테이블에 "Orders"라는 이름의 레코드가 없을 경우 테이블에 일부 항목을 삽입하는 SQL 쿼리를 실행해야 합니다.지금까지 저는 이렇게 했습니다.
IF NOT EXISTS (
SELECT
*
FROM
gridconfigs
WHERE
gridconfigs.name = 'Orders'
)
INSERT INTO
`gridconfigs` (
`ownerId`,
`classId`,
`name`,
`searchType`,
`type`,
`config`,
`description`,
`creationDate`,
`modificationDate`,
`shareGlobally`
)
VALUES(
....
그리고 이것이 제가 받고 있는 오류입니다.
Errore nella query (1064): Syntax error near 'INSERT INTO `gridconfigs` ( `ownerId`, `classId`, `name`, ...' at line 9
나는 그 오류가 실제로 무엇인지 이해하지 못합니다.
값에 삽입 대신 존재하는 SELECT를 작성할 수 있습니다.
CREATE TABLE `gridconfigs` (
`ownerId` int,
`classId` int,
`name` varchar(19),
`searchType` int,
`type` int,
`config` int,
`description` int,
`creationDate` int,
`modificationDate` int,
`shareGlobally` int
)
;
INSERT INTO gridconfigs
VALUES
(1,2,'Orders',4,5,6,7,8,9,10)
;
INSERT INTO
`gridconfigs` (
`ownerId`,
`classId`,
`name`,
`searchType`,
`type`,
`config`,
`description`,
`creationDate`,
`modificationDate`,
`shareGlobally`
)
SELECT
1,2,3,4,5,6,7,8,9,10
WHERE NOT EXISTS ( SELECT 1 FROM gridconfigs WHERE gridconfigs.name = 'Orders')
Records: 0 Duplicates: 0 Warnings: 0
언급URL : https://stackoverflow.com/questions/73774218/how-to-understand-where-the-error-is-in-a-sql-query-that-fails-with-this-message
반응형
'sourcecode' 카테고리의 다른 글
플라스크의 '종점'은 무엇입니까? (0) | 2023.06.08 |
---|---|
두 개 이상의 벡터에서 모든 요소의 고유한 조합 (0) | 2023.06.08 |
오류 TS2318: 글로벌 유형 '개체'를 찾을 수 없습니다. (0) | 2023.06.08 |
sqlite 쿼리에서 딕트를 가져오려면 어떻게 해야 합니까? (0) | 2023.06.08 |
Mongodb 정렬 내부 배열 (0) | 2023.06.08 |