比较MySQL表php中设置的两个值

时间:2013-08-14 13:20:15

标签: php mysql database-schema

我有一个mysql表有2列,claim_status和show(两个VARCHAR(500))我用int测试不起作用。

我只想查询有claim_status ='0'和show ='1'的项目

现在我的PHP代码没有返回任何内容:

$query  = "SELECT COUNT(*) as num FROM $tableName WHERE claim_status='0' AND show='1'";
$query1 = "SELECT * FROM $tableName WHERE claim_status='0' AND show='1'";

**它在这条线上失败了** $ query =“SELECT COUNT(*)as num FROM $ tableName WHERE claim_status = 0 AND show = 1”;

1 个答案:

答案 0 :(得分:0)

 $query = SELECT * FROM tablename WHERE claim_status='0' AND show='1'; 
    $result =  mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}