我有2个表,members
和appoint
。在appoint
我有members_id
。这是对的吗?
$result = mysql_query ("SELECT * FROM members,appoint WHERE members_id=id ORDER BY id");
while ($row = mysql_fetch_array ($result))
这会返回此错误“Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given
”
有什么想法吗?
答案 0 :(得分:1)
使用
的显式连接语法SELECT * FROM members
INNER JOIN appoint ON members.id = appoint.members_id
ORDER BY members.id
最好在引用列时使用表名。如果两个表具有相同的列名,则DB将不知道要采用哪一个。
答案 1 :(得分:0)
你可以试试这个
SELECT m.*, a.* FROM members AS m JOIN appoint AS a ON m.members_id = a.id ORDER BY a.id ASC