MYSQLI错误 - 帮助搜索语法 - JOIN

时间:2014-02-03 11:15:03

标签: php mysql sql mysqli

警告:mysqli_fetch_row()期望参数1为mysqli_result,在....中给出布尔值。

您好。我收到了上述错误。我做了一些JOINS,但还不足以调试问题/获得经验。

此代码工作正常。

    (SELECT ClientNumber FROM ClientCodes where (nextCheck<'$timer') LIMIT $start,5);

   (SELECT * FROM ClientCodes where (nextCheck<'$timer') LIMIT $start,5);
基本上,我想'加入'2桌 - &amp;从另一个表中导入“名称”列 - 基于客户编号。

到目前为止我所拥有的SQL代码是这样的,但我遇到了各种错误。 (这是我的第5个/第6版本的代码,但它仍然会出错...)

     SELECT t1.*, t2.Name
     FROM `ClientCodes` AS t1 
     JOIN Clientlist AS t2 ON ClientCodes.ClientNumber = Clientlist.Clientnumber
     WHERE Clientlist.clientnumber = (SELECT ClientNumber FROM ClientCodes
     where (nextCheck<'$timer') LIMIT $start,5);";

(Name列在Clientlist表中。)

1 个答案:

答案 0 :(得分:1)

请尝试以下查询:

SELECT t1.*, t2.Name

FROM
(

  SELECT * FROM ClientCodes WHERE (nextCheck<'$timer') LIMIT $start,5

) AS t1

JOIN Clientlist AS t2 

ON t1.ClientNumber = t2.Clientnumber