Solved

MySQL update based on data from another table

Posted on 2009-04-15
4
204 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 92

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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
database connection error mysql stops 7 79
SSIS Combine projects into one 2 32
Data conversion error in SSIS 3 53
Intermittent OleDbConnection Error 20 44
This article explains all about SQL Server Piecemeal Restore with examples in step by step manner.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
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…

739 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