这个mysql语法有什么问题?我将它复制到 phpmyadmin 并完美运行。当我试图从 php 中获取数组时,它返回了“bool(false)”错误。
(
SELECT
id,
cim,
'news' as kat
FROM
mbsz_news
WHERE
cim LIKE '%anystring%'
OR lead LIKE '%anystring%'
OR content LIKE '%anystring%'
)
UNION
(
SELECT
id,
p_name,
'plaza' as kat
FROM
mbsz_plazas
WHERE
p_name LIKE '%anystring%'
OR uzemelteto LIKE '%anystring%'
)
UNION
(
SELECT
id,
cim,
'book' as kat
FROM
mbsz_konyvtar
WHERE
cim LIKE '%anystring%'
OR kszam LIKE '%anystring%'
OR kiado LIKE '%anystring%'
)
PHP代码:
$res = mysql_query($sql);
while($row = mysql_fetch_array($res))
{
echo $row['type'];
}
$res
给出错误 bool(false) 感谢您的帮助。