How do I write a proper SQL INNER JOIN UPDATE?

The attached SQL statement isn't working.  Would someone talk a look at my syntax?

$q2 = "UPDATE documents AS d INNER JOIN document_tracks AS dt USING (doc_id) SET d.listens = '$listen_total' WHERE dt.doc_id = '$arr1[1]'";
tprofitsAsked:
Who is Participating?
 
Kevin CrossConnect With a Mentor Chief Technology OfficerCommented:
For MySQL that syntax looks correct.
UPDATE table1 t1 INNER JOIN table2 t2 USING(id)
SET t1.data = 'some value'
WHERE t2.somecolumn = 'some other value'

Open in new window

0
 
Kevin CrossChief Technology OfficerCommented:
What is the database backend?  MySQL?  SQL Server?  What version?
0
 
tprofitsAuthor Commented:
MySQL 5.
0
 
tprofitsAuthor Commented:
Now that the syntax is definitely correct, I moved on and found the problem in a different spot.  Thanks.
0
 
Kevin CrossChief Technology OfficerCommented:
Glad I was able to help confirm.

Good luck and happy coding!

Regards,
Kev
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.