0

Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in ....

Hello. I'm getting the above error. i have done a few JOINS, but not enough to debug problems / gain experience with them.

this code works fine.

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

or

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

basically, i want to 'join' 2 tables - & import the 'name' column from another table - based on the client number.

the SQL code i have so far is this, but i'm getting various errors. (this is my 5th/6th version of this code, but it still gets errors...)

     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);";

(the Name column is in the Clientlist table.)

G Stewpot
  • 99
  • 1
  • 2
  • 10
  • If you substitute `=` in your `WHERE` clause with `IN` - what happens? – Alexander Feb 03 '14 at 11:17
  • i get similar error - Warning: mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in ... .... – G Stewpot Feb 03 '14 at 11:22
  • SELECT t1.*, t2.Name FROM `ClientCodes` AS t1 JOIN Clientlist AS t2 ON ClientCodes.ClientNumber = Clientlist.Clientnumber WHERE Clientlist.clientnumber IN (SELECT ClientNumber FROM ClientCodes where (nextCheck – G Stewpot Feb 03 '14 at 11:23

1 Answers1

1

Please try the following query:

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
vidang
  • 1,756
  • 13
  • 13
  • Thankyou. I'll add this to my aresenal / catalogue of good codes for future. its easy to undersatnd if I put FROM(..) in brackets & add the small Join tags on the outside. – G Stewpot Feb 04 '14 at 04:44
  • I'm glad that I could help – vidang Feb 04 '14 at 06:55