简体   繁体   中英

Updating table with INNER JOIN, using mysqli

I am trying to update a table with using INNER JOIN. What I am trying to do is to get the 'username' which has the 'code' value, and update a value of that "username" on another table.

I tried this:

$pbr = $conn->prepare("UPDATE p 
                       SET p.pay = p.pay + 10 
                       FROM points AS p 
                       INNER JOIN members AS m 
                       ON p.username = m.username 
                       WHERE m.code = ?");
$pbr->bind_param("s", $code);

That gives me "Fatal error: Call to a member function bind_param() on a non-object "

I searched and found some questions like mine but I can't solve this. I used var_dump($pbr); and it gives "boolean false", but I can't see where the problem is.

The query should look like this:

$pbr = $conn->prepare("UPDATE points p 
                       INNER JOIN members AS m 
                       ON p.username = m.username 
                       SET p.pay = p.pay + 10 
                       WHERE m.code = ?");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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