简体   繁体   English

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

[英]Comparing two values set in MySQL table php

I have a mysql table that has 2 columns, claim_status and show (both VARCHAR(500)) I tested with int didn't work. 我有一个具有2列的mysql表,claim_status和show(都是VARCHAR(500)),我用int测试过后不起作用。

I want to query only the items that have claim_status='0' and show='1' 我只想查询具有Claim_status ='0'和show ='1'的项目

right now nothing is returned here is my PHP code: 现在什么都没有返回,这是我的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'";

** it fails on this line ** $query = "SELECT COUNT(*) as num FROM $tableName WHERE claim_status=0 AND show=1"; **它在此行上失败** $ query =“ SELECT COUNT(*)as num FROM $ tableName WHERE Claim_status = 0 AND show = 1”;

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM