我正在试图弄清楚为什么我的CMS给了我一个错误,但SQLFiddle和phpMyAdmin都运行查询。这是小提琴:
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', 'ss@gmail.com', 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'
......它吐出错误:
非法混合排序(utf8mb4_bin,IMPLICIT)和 (utf8_general_ci,COERCIBLE)用于操作'='
我对从utf8_general_ci
获得的地方感到困惑?我必须错过一些愚蠢的东西,但我看不到它。希望一副新鲜的眼睛会有所帮助!
感谢您的任何建议!
答案 0 :(得分:1)
SET collation_connection = 'utf8mb4_bin'
:
SET collation_connection = 'utf8mb4_bin';
SELECT * FROM glinks_Sales WHERE (TransactionID = ?) ORDER BY Order_Date ASC';
在运行查询之前,这将设置连接的排序规则。
如果不起作用,请检查数据库,服务器或连接的其他可能的排序规则设置。您可以在此处找到一些提示:https://stackoverflow.com/a/37298732/1363190