我正在使用以下查询:
$sql = $db->Query("SELECT a.id, a.t_name, a.cpc FROM twitter a LEFT JOIN users b ON b.id = a.user LEFT JOIN followed c ON c.user_id = '".$data['id']."' AND c.site_id = a.id WHERE a.active = '0' AND (b.coins >= a.cpc AND a.cpc >= '2') AND (c.site_id IS NULL AND a.user !='".$data['id']."')".$dbt_value." ORDER BY a.cpc DESC".($site['mysql_random'] == 1 ? ', RAND()' : '')." LIMIT 14");
但我想补充一点:
AND (a.d_max > '0' OR a.d_max = u) AND (a.max > '0' OR a.max = u)
所以我将其添加到:
$sql = $db->Query("SELECT a.id, a.t_name, a.cpc FROM twitter a LEFT JOIN users b ON b.id = a.user LEFT JOIN followed c ON c.user_id = '".$data['id']."' AND c.site_id = a.id WHERE a.active = '0' AND (a.d_max > '0' OR a.d_max = u) AND (a.max > '0' OR a.max = u) AND (b.coins >= a.cpc AND a.cpc >= '2') AND (c.site_id IS NULL AND a.user !='".$data['id']."')".$dbt_value." ORDER BY a.cpc DESC".($site['mysql_random'] == 1 ? ', RAND()' : '')." LIMIT 14");
但是我收到以下错误:
SQL 错误:“where 子句”中的未知列“u”:
我知道这应该很简单,但我只是想念它,你们能找出问题所在吗?