mysql WHERE CLAUSE未返回SQL中的任何内容[已关闭]

qfe3c7zg  于 2022-12-17  发布在  Mysql
关注(0)|答案(1)|浏览(69)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包含desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
昨天关门了。
Improve this question
救命!
我试图获取列member_casual为casual的列,但它没有返回任何结果。我检查了数据类型,发现它是varchar。我甚至放了一个trim函数,以确保它没有任何空格(我也尝试过不使用该函数),但它不起作用。

SELECT *
FROM table_example
WHERE TRIM(member_casual) = 'casual';

数据:
enter image description here
两行示例:

00000123F60251E6,classic_bike,2022-02-07 15:47:40,2022-02-07 15:49:28,Wells St & Hubbard St,TA1307000151,Kingsbury St & Kinzie St,KA1503000043,42,-88,42,-88,member
-----------
,00:01:48,2
00000179CF2C4FB5,electric_bike,2022-07-28 09:02:27,2022-07-28 09:13:51,Ellis Ave & 55th St,KA1504000076,Ellis Ave & 55th St,KA1504000076,42,-88,42,-88,casual

我只想要member_casual为“causal”的列。我尝试了trim函数,尝试了“",”..."列数据类型为varchar。

k7fdbhmy

k7fdbhmy1#

有一些函数可以帮助调试,例如hex,unhex,length

select  length(trim(CAST(unhex('63617375616C0D') AS CHAR(10)))),
        hex(replace(
        (CAST(unhex('63617375616C0D') AS CHAR(100)))
        ,'\r','')
        )

+---------------------------------------------------------+-----------------------------------------------------------------------+
| length(trim(CAST(unhex('63617375616C0D') AS CHAR(10)))) | hex(replace(
(CAST(unhex('63617375616C0D') AS CHAR(100)))
,'\r','')
) |
+---------------------------------------------------------+-----------------------------------------------------------------------+
|                                                       7 | 63617375616C                                                          |
+---------------------------------------------------------+-----------------------------------------------------------------------+
1 row in set (0.076 sec)

显然,长度7是意外的... REPLACE删除了0D

相关问题