MYSQL 잘린 잘못된 DOUBLE 값
아래 SQL 쿼리가 실행될 때 :
UPDATE shop_category
SET name = 'Secolul XVI - XVIII'
AND name_eng = '16th to 18th centuries'
WHERE category_id = 4768
다음과 같은 오류가 발생합니다.
1292 - Truncated incorrect DOUBLE value: 'Secolul XVI - XVIII'
이 문제를 해결하는 방법?
shop_category
테이블 구조 :
category_id mediumint(8)
name varchar(250)
name_eng varchar(250)
AND
키워드 가 필요하지 않습니다 . UPDATE 문의 올바른 구문은 다음과 같습니다 .
UPDATE
shop_category
SET
name = 'Secolul XVI - XVIII',
name_eng = '16th to 18th centuries'
WHERE
category_id = 4768
쉼표 대신 AND가 아닌이 예외가 발생했습니다. 실제로 where 절에서 아포스트로피를 사용하지 않았기 때문에이 예외가 발생했습니다.
내 검색어처럼
update table set coulmn1='something' where column2 in (00012121);
where 절을 where column2 in ('00012121');
다음으로 변경 하면 쿼리가 제대로 작동했습니다.
를 교체 시도 AND
와 함께,
UPDATE shop_category
SET name = 'Secolul XVI - XVIII', name_eng = '16th to 18th centuries'
WHERE category_id = 4768
UPDATE 구문 나타낸다 쉼표 세퍼레이터로서 사용되어야한다.
방금 시간을 낭비 하고이 오류가 발생하는 경우를 추가하고 싶었습니다.
SQL Error (1292): Truncated incorrect DOUBLE value: 'N0003'
테스트 데이터
CREATE TABLE `table1 ` (
`value1` VARCHAR(50) NOT NULL
);
INSERT INTO table1 (value1) VALUES ('N0003');
CREATE TABLE `table2 ` (
`value2` VARCHAR(50) NOT NULL
);
INSERT INTO table2 (value2)
SELECT value1
FROM table1
WHERE 1
ORDER BY value1+0
문제는 ORDER BY value1+0
유형 캐스팅입니다.
질문에 답하지는 않지만 Google 에서이 오류의 첫 번째 결과 이며이 오류가 나타나는 다른 예가 있어야합니다.
주로 잘못된 쿼리 문자열이이 경고를 표시합니다.
INSTR
함수를 사용할 때 미묘한 구문 오류 (오른쪽 괄호가 잘못됨)로 인해 잘못되었습니다 .
INSERT INTO users (user_name) SELECT name FROM site_users WHERE
INSTR(status, 'active'>0);
옳은:
INSERT INTO users (user_name) SELECT name FROM site_users WHERE
INSTR(status, 'active')>0;
기본적으로
잘못된 구문은 MySQL이 "DOUBLE"유형의 열 또는 매개 변수로 무언가를 시도한다고 생각하게합니다.
내 실수에서 배운다
필자의 경우 NULL
값이 0
서있는 테이블 설정 에서 varchar 열을 업데이트했습니다 . 내 업데이트 쿼리는 다음과 같습니다.
UPDATE myTable SET myValue = NULL WHERE myValue = 0;
지금의 실제 유형부터 myValue
이다 VARCHAR(255)
이 경고를 제공합니다 :
+---------+------+-----------------------------------------------+
| Level | Code | Message |
+---------+------+-----------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'value xyz' |
+---------+------+-----------------------------------------------+
And now myTable
is practically empty, because myValue
is now NULL
for EVERY ROW in the table! How did this happen?
*internal screaming*
Over 30k rows now have missing data.
*internal screaming intensifies*
Thank goodness for backups. I was able to recover all the data.
*internal screaming intensity lowers*
The corrected query is as follows:
UPDATE myTable SET myValue = NULL WHERE myValue = '0';
^^^
Quotation here!
I wish this was more than just a warning so it's less dangerous to forget those quotes.
*End internal screaming*
If you're getting this problem with an insert that looks like the one below, the problem may simply be the lack of a space between --
and the comment text:
insert into myTable (a, b, c)
values (
123 --something
,345 --something else
,567 --something something else
);
The problem with this is that the --something
should actually be -- something
with a space.
It seems mysql handles the type casting gracefully with SELECT statements. The shop_id field is of type varchar but the select statements works
select * from shops where shop_id = 26244317283;
But when you try updating the fields
update stores set store_url = 'https://test-url.com' where shop_id = 26244317283;
It fails with error Truncated incorrect DOUBLE value: '1t5hxq9'
You need to put the shop_id 26244317283 in quotes '26244317283' for the query to work since the field is of type varchar not int
update stores set store_url = 'https://test-url.com' where shop_id = '26244317283';
참고URL : https://stackoverflow.com/questions/3456258/mysql-truncated-incorrect-double-value
'Programming' 카테고리의 다른 글
typescript : 오류 TS2693 : 'Promise'는 유형 만 참조하지만 여기서 값으로 사용 중입니다. (0) | 2020.06.27 |
---|---|
Objective-C의 MD5 알고리즘 (0) | 2020.06.27 |
클래스 선택기와 속성 선택기를 jQuery와 결합 (0) | 2020.06.27 |
Java 8 스트림과 RxJava 옵저버 블의 차이점 (0) | 2020.06.27 |
Spring MVC @PathVariable가 잘림 (0) | 2020.06.27 |