即使閱讀所有相關的主題工作後,沒有什麼幫助:計數都不能正確使用UNION
$q="select count(*) from (
SELECT COUNT(*) AS total
FROM clips
WHERE ((dimensions like('%concert%') AND dimensions NOT like('concert'))
OR (file_format like('%concert%') AND file_format NOT like('concert')))
UNION DISTINCT
SELECT COUNT(*) AS total
FROM clips
WHERE (dimensions like('concert') OR file_format like('concert'))
) AS num";
$q2 = mysql_query($q) or die(mysql_error());
$q3 = mysql_fetch_array($q2);
echo $q3['num'];
的錯誤,我得到:
注意:未定義指數:NUM中....在線..
我在做什麼錯?
什麼在$ Q3 :)做過的var_dump上呢? – Brian
array(2){[0] => string(1)「1」[「count(*)」] => string(1)「1」} – Mark
您的AS號是錯誤的。 –