我知道這裏有很多像這樣的錯誤,但是這個查詢看起來不同,因爲它是插入查詢。下面是表card_info模式:Mysql在INSERT查詢中截斷不正確的DOUBLE值
CREATE TABLE card_info (
card_id mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
card_name_orig varchar(150) NOT NULL,
card_name_html varchar(150) NOT NULL,
card_name_search varchar(150) NOT NULL,
card_name_page varchar(150) NOT NULL,
card_cost varchar(50) DEFAULT NULL,
card_cost_converted tinyint(2) NOT NULL DEFAULT '0',
card_subtype varchar(75) DEFAULT NULL,
card_oracle_text_orig text,
card_oracle_text_html text,
card_power varchar(10) DEFAULT NULL,
card_toughness varchar(10) DEFAULT NULL,
card_loyalty tinyint(1) DEFAULT NULL,
PRIMARY KEY (card_id),
KEY card_name_nd (card_name_search),
KEY card_name_page (card_name_page),
KEY card_cost_converted (card_cost_converted),
KEY card_power (card_power),
KEY card_toughness (card_toughness),
KEY card_loyalty (card_loyalty),
FULLTEXT KEY card_oracle_text_orig (card_oracle_text_orig),
FULLTEXT KEY card_name_search (card_name_search)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
,這裏是我的查詢:
INSERT INTO card_info (
card_name_orig, card_name_html, card_name_search, card_name_page, card_cost,
card_cost_converted, card_subtype, card_oracle_text_orig, card_oracle_text_html,
card_power, card_toughness, card_loyalty
)
SELECT DISTINCT
d.name_orig, d.name_html, d.name_search, d.name_page, d.cost,
COALESCE(d.cost_converted, 0), d.type_sub, d.oracle_text_orig,
d.oracle_text_html, d.`power`, d.toughness, d.loyalty
FROM card_info_de d
LEFT OUTER JOIN card_info i ON d.name_search = i.card_name_search
WHERE i.card_id IS NULL
AND d.edition_id = 'isd'
ORDER BY (d.collector_number + 0), d.collector_number;
如果我執行此查詢,我得到這個錯誤:
1292 - 截斷不正確DOUBLE值: '181A'
請注意,該值181A從列。 collector_number
並且它是一個VARCHAR(5)字段,並且該字段沒有被插入到card_info
表無論如何,它只是被選擇查詢的順序子句中使用。
如果我只從SELECT
開始查詢,我可以看到正確的結果被選中,但是當我插入時,它給了我上面的錯誤。請注意,如果我從SELECT查詢中刪除ORDER BY子句,它會插入正常。我不知道我做錯了什麼。
在此先感謝。
你可以分享表card_info –
我的模式更新噸他質疑該模式。感謝您的時間。 – voldomazta