Solved

MySQL update based on data from another table

Posted on 2009-04-15
4
193 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
4 Comments
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
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
Comment Utility
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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Many companies are looking to get out of the datacenter business and to services like Microsoft Azure to provide Infrastructure as a Service (IaaS) solutions for legacy client server workloads, rather than continuing to make capital investments in h…
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…

762 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

12 Experts available now in Live!

Get 1:1 Help Now