[英]What is wrong with my two table sql Query?
I am trying to select customerid in the envents table and where it is the same as the customerid in the customers' table and the session loginid equals the loginid in the customers table. 我试图在envents表中选择customerid,它与客户表中的customerid相同,而会话loginid等于customers表中的loginid。
$result = mysql_query("SELECT event.customerid, customer.customerid,
customer.loginid,customer.email". "FROM even, customer"."
WHERE event.customerid = customer.customerid AND
customer.loginid = ". $_SESSION['SESSLOGINID']);
missing space before FROM FROM前缺少空格
$result = mysql_query("SELECT event.customerid, customer.customerid,
customer.loginid,customer.email". " FROM even, customer"."
WHERE event.customerid = customer.customerid AND
customer.loginid = ". $_SESSION['SESSLOGINID']);
edit: and please don't ignore the comment of tadman 编辑:并且请不要忽略塔德曼的评论
You're missing a space between customer.email
and FROM
. 您在customer.email
和FROM
之间缺少空格。 You're also missing a t
on event
. 你还缺少一个t
的event
。
Your query should read: 您的查询应为:
$result = mysql_query("SELECT event.customerid, customer.customerid,
customer.loginid,customer.email". " FROM event, customer"."
WHERE event.customerid = customer.customerid AND
customer.loginid = ". $_SESSION['SESSLOGINID']);
If you looked at the error message you were getting, you would at least get close to the problem. 如果查看收到的错误消息,至少可以解决问题。 If you then looked carefully at the query (copy & paste to a variable and dump it), you should notice the problem. 然后,如果您仔细查看查询(将其复制并粘贴到变量并转储到变量中),则应该注意到该问题。
Additional note: Before you go any further you should read about SQL injection if you have not already. 补充说明:如果您还没有SQL注入,则应该继续阅读。 Also, as @tadman points out, mysql_*
functions are deprecated and should not be used in new code. 此外,正如@tadman指出的那样,不建议使用mysql_*
函数,因此不应在新代码中使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.