即使sql查询正确,也返回空集

时间:2016-09-22 09:30:21

标签: mysql

我有一个名为states的表。数据是这样的:

+----------------------+--------------------+
| value                | name               |
+----------------------+--------------------+
| andaman-nicobar-map  | Andaman-Nicobar    |
| andhra-pradesh-map   | Andhra-Pradesh     |
| arunachal-map        | Arunachal          |
| assam-map            | Assam              |
| bihar-map            | Bihar              |
| chandigarh-map       | Chandigarh         |
| chattisgarh-map      | Chattisgarh        |
| daman-map            | Daman              |
+----------------------+--------------------+

SELECT * FROM `states` WHERE `name`='Bihar'; 

但此查询返回一个空结果集。

1 个答案:

答案 0 :(得分:0)

我的猜测是你在SELECT * FROM states WHERE TRIM(name) = 'Bihar' 列中有空格,这就是为什么确切的比较失败了。试试这个问题:

SELECT *
FROM states
WHERE name LIKE '%Bihar%'

或者这个:

name

如果其中任何一项有效,那么您就会知道 class Program { static void Main(string[] args) { Maruti objMaruti = new Maruti(); clientClass obj = new clientClass(objMaruti); obj.getSpeed(); } } public class clientClass { ISpeed _ISpeed; public clientClass(ISpeed obj) { this._ISpeed = obj; } public int getSpeed() { return _ISpeed.Speed(); } } public interface ISpeed { int Speed(); } public class Maruti : ISpeed { public int Speed() { return 200; } } public class Audi : ISpeed { public int Speed() { return 400; } } public class BMW : ISpeed { public int Speed() { return 600; } } 列中有额外的字符。