UNION在phpmyadmin工作,但不是在我的PHP代码 [英] UNION working in phpmyadmin, but not in my PHP code

查看:158
本文介绍了UNION在phpmyadmin工作,但不是在我的PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以下面的查询将运行在我的phpmyadmin(变量作为实际值作为课程),但是当我在我的PHP代码中运行它只返回第一个字段(如果UNION之后的第二个查询从来没有跑)。

so the query below will run in my phpmyadmin (with the variables as actual values as course), but when I run it in my php code I only get the first field returned (as if the second query after the UNION was never run).

$result=mysql_query("(SELECT RID, Name, Address, City, State, Zip_Code, Phone 
                      FROM restaurant 
                      WHERE Name = '$sql_name' AND City = '$sql_location') 
                      UNION 
                      (SELECT RID, Name, Address, City, State, Zip_Code, Phone 
                      FROM restaurant 
                      WHERE Name = '$sql_name' OR City = 'sql_location') ");

任何人都可以帮助我解释为什么会这样?

Can anyone help me as to why this is? Thanks for reading and I appreciate any and all help.

推荐答案

City = 'sql_location')
        ^ missing '$' symbol

这篇关于UNION在phpmyadmin工作,但不是在我的PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆