Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试运行一个 SELECT 查询,该查询会提取以 T 开头的姓氏。当我运行它时,我只得到 0 个结果,但表中确实有以字母 T 开头的名称。
我究竟做错了什么?
这是我的代码
SELECT FirstName, LastName, City FROM Customers WHERE LastName LIKE 'T%';
最可能的原因是LastName列值中有前导空格。
LastName
查找至少有一个前导空格的所有条目
SELECT FirstName, LastName, City FROM Customers WHERE LastName LIKE ' %';
这是SQLFiddle演示
要修复此类条目,您可以执行
UPDATE Customers SET LastName = TRIM(LastName) WHERE LastName LIKE ' %';