简体   繁体   中英

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.

I want to query only the items that have claim_status='0' and show='1'

right now nothing is returned here is my PHP code:

$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 * FROM tablename WHERE claim_status='0' AND show='1'; 
    $result =  mysql_query($query);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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