Solved

How do I write a proper SQL INNER JOIN UPDATE?

Posted on 2009-04-08
5
175 Views
Last Modified: 2012-05-06
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]'";
0
Comment
Question by:tprofits
  • 3
  • 2
5 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24097581
What is the database backend?  MySQL?  SQL Server?  What version?
0
 

Author Comment

by:tprofits
ID: 24097597
MySQL 5.
0
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 24097683
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
 

Author Closing Comment

by:tprofits
ID: 31568047
Now that the syntax is definitely correct, I moved on and found the problem in a different spot.  Thanks.
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 24098495
Glad I was able to help confirm.

Good luck and happy coding!

Regards,
Kev
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sql calculate averages 18 47
Substring() and LEFT() syntax 4 21
grouping logic 6 49
SQL Query Conversion of IIF statement into CASE - Syntax issue 17 33
As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now