Hello. I need some help to update two table.. This is my coding:

$query = "UPDATE br.discharged_Date, b.book_Status SET 
                br.patron_ID = b.patron_ID
                FROM borrow br
                INNER JOIN book b
                ON br.patron_ID = b.patron_ID
                WHERE b.patron_ID = '$patron_ID'";

Recommended Answers

All 3 Replies

Your're only updating one column in table br here. You can use joins like this to update 2 tables but you'd need to include the second column of the second table in the SET part of the command.
To be perfectly honest, the entire command is a bit wrong for a UPDATE statement. You don't the FROM for example.
The mysql docs might be useful Click Here

Your query is all wrong: you are asking the database to update, not a table but a row. The update query should be something like: 'UPDATE atable SET atable.acolumn = avalue.....

UPDATE Table1, Table2
SET Table1.LastName = 'DR. XXXXXX' 
,Table2.WAprrs = 'start,stop'
FROM Table1 T1, Table2 T2
WHERE T1.id = T2.id
and T1.id = '010008'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.