我想弄清楚爲什麼我的CMS給我一個錯誤,但SQLFiddle和phpMyAdmin都運行查詢罰款。這裏是小提琴:mySQL:非法混合的排序規則(utf8mb4_bin,IMPLICIT)和(utf8_general_ci,COERCIBLE)操作'='
http://sqlfiddle.com/#!9/cadc53/2
因此,樣本數據:
CREATE TABLE IF NOT EXISTS `glinks_Sales` (
`TransactionID` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`Billing_Name` char(255) COLLATE utf8mb4_bin DEFAULT NULL,
`Billing_Street` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Billing_City` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Billing_State` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Billing_PostCode` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Billing_Country` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Shipping_Name` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Shipping_Street` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Shipping_City` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Shipping_State` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Shipping_PostCode` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Shipping_Country` varchar(255) COLLATE utf8mb4_bin NOT NULL,
`Been_Dispatched` int(11) NOT NULL,
`Postcode_Check_Status` varchar(10) COLLATE utf8mb4_bin DEFAULT NULL,
`Billing_Street_2` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`Shipping_Street_2` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`Items_In_Order` longtext COLLATE utf8mb4_bin,
`Email` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
`unique_id` int(11) NOT NULL,
`Order_Date` bigint(20) DEFAULT NULL,
`Method` char(10) COLLATE utf8mb4_bin DEFAULT NULL,
`Currency` char(3) COLLATE utf8mb4_bin DEFAULT NULL,
`Shipping_Amount` float DEFAULT NULL,
`Language` varchar(5) COLLATE utf8mb4_bin DEFAULT NULL,
`Cancelled` int(11) DEFAULT NULL,
`TrackingNumber` varchar(200) COLLATE utf8mb4_bin DEFAULT NULL,
`PostageCompany` varchar(200) COLLATE utf8mb4_bin DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
ALTER TABLE `glinks_Sales`
ADD PRIMARY KEY (`unique_id`);
INSERT INTO `glinks_Sales` (`TransactionID`, `Billing_Name`, `Billing_Street`, `Billing_City`, `Billing_State`, `Billing_PostCode`, `Billing_Country`, `Shipping_Name`, `Shipping_Street`, `Shipping_City`, `Shipping_State`, `Shipping_PostCode`, `Shipping_Country`, `Been_Dispatched`, `Postcode_Check_Status`, `Billing_Street_2`, `Shipping_Street_2`, `Items_In_Order`, `Email`, `unique_id`, `Order_Date`, `Method`, `Currency`, `Shipping_Amount`, `Language`, `Cancelled`, `TrackingNumber`, `PostageCompany`) VALUES ('8LL79654AS664260H', 'Andyííííééé Íóé', 'xxxx', 'Rudgwick', 'West Sussex', 'xxx', 'GB', 'Andyííííééé Íóé ', 'foo', 'x', 'West Sussex', 'x', 'GB', 1488558170, '1', '', '', 'test', '[email protected]', 15, 1488472336, 'PayPal', '', 10, 'en', NULL, 'foo', 'royal mail');
然後樣本查詢搶
SELECT * FROM glinks_Sales WHERE (Shipping_Name = "Andyííííééé Íóé" OR Email = "Íóé" OR unique_id = "Íóé" OR TrackingNumber = "Íóé" OR PostageCompany = "Íóé")
運行就好了。但是,訪問數據庫我的Perl腳本的作用:
SELECT * FROM glinks_Sales WHERE (TransactionID = ?) ORDER BY Order_Date ASC'
...它吐出錯誤:
Illegal mix of collations (utf8mb4_bin,IMPLICIT) and (utf8_general_ci,COERCIBLE) for operation '='
我很困惑,它會從得到utf8_general_ci
?我一定錯過了一些愚蠢的東西,但我看不到它。希望一雙新鮮的眼睛能夠幫到你!
感謝您的任何建議!
排序混合可能是一種痛苦。嘗試'SET collation_connection ='utf8mb4_bin'',如果不工作,檢查數據庫,服務器或連接其他可能的排序規則設置:http://stackoverflow.com/a/37298732/1363190 –
謝謝 - 第一位做的工作我:)請添加它作爲答案,我會接受。這節省了很多我的頭髮!大聲笑 –
很高興聽到它爲你解決。我現在已經創建了一個答案,如果你接受它,那就很開心。 –