?
Solved

MySQL update based on data from another table

Posted on 2009-04-15
4
Medium Priority
?
206 Views
Last Modified: 2012-05-06
I need to update a field in a table based on a field from another table. I am only familiar with using Joins with a Select statement so I know my syntext is wrong... can someone please show me the correct syntext.
Update HanStores T SET T.AuditCompany = 'WRP' 
Left outer join HanAR T1 On T.StoreNum = T1.StoreID
Where T1.Auditor LIKE 'Carl%'

Open in new window

0
Comment
Question by:dannyg280
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 24148374
Update HanStores
SET AuditCompany = 'WRP'
FROM HanStores T Left outer join
      HanAR T1 On T.StoreNum = T1.StoreID
Where T1.Auditor LIKE 'Carl%'
0
 

Author Comment

by:dannyg280
ID: 24149064
Thanks for the responce.... I'm still getting a syntext error
"#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM HanStores T
Left outer join
      HanAR T1 On T.StoreNum = T1.StoreID
' at line 3
"

I'm using MySQL 5.0
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 24151258
a OUTER join  does not make any sense in your example..
http://dev.mysql.com/doc/refman/5.0/en/update.html
Update HanStores T, HanAR T1  
  SET T.AuditCompany = 'WRP' 
WHERE T.StoreNum = T1.StoreID
 and T1.Auditor LIKE 'Carl%'

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

743 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