从php mysql获取数组结果中过滤掉特定行

时间:2011-01-16 15:40:55

标签: php mysql sql

我有一个sql表,如下所示

+---+-------+-----+   
|Sl | Name  |Value|   
+---+-------+-----+   
| 1 | Name1 | 1   | 
| 2 | Name2 | 2   |
| 3 | Name3 | 2   |  
| 4 | Name4 | 3   |
| 5 | Name5 | 4   |
+---+-------+-----+   

我有一个php查询$query3 = "select * from table";

查询返回所有行和我需要的列。但我想在“Value”列中排除值为2的行,如下所示;

+---+-------+-----+   
|Sl | Name  |Value|   
+---+-------+-----+   
| 1 | Name1 | 1   |  
| 4 | Name4 | 3   |
| 5 | Name5 | 4   |
+---+-------+-----+ 

1 个答案:

答案 0 :(得分:0)

SELECT `Sl`, `Name`, `Value` from `table` WHERE `Value` != 2