简体   繁体   English

使用MySQL比较PHP中两个表的两个ID

[英]Comparing two ids from two tables in php using mysql

This is the SQL statement I have written. 这是我编写的SQL语句。

$result_array 
   = mysql_query("SELECT * FROM pl_fixtures WHERE id = pl_divisions.id", $con1);

It is written to compare values of dbfix.id with dbdiv.id. 编写该脚本是为了将dbfix.id的值与dbdiv.id进行比较。 Can someone please tell me what is my error in comparing these two "id"s? 有人可以告诉我比较这两个“ id”的错误吗? dbfix and dbdiv are two different tables in a same database. dbfix和dbdiv是同一数据库中的两个不同的表。 Both have id as primary keys. 两者都具有id作为主键。 I am using PHP 5. 我正在使用PHP 5。

Any help will be appreciated. 任何帮助将不胜感激。 Thank you :) 谢谢 :)

Regards, BG 问候,BG

You aren't including the pl_divisions table in your select. 您未在选择中包括pl_divisions表。 Try the following: 请尝试以下操作:

$result_array = mysql_query("SELECT * FROM pl_fixtures, pl_divisions WHERE pl_fixtures.id = pl_divisions.id", $con1);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM