Solved

MySQL update based on data from another table

Posted on 2009-04-15
4
202 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
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 142

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
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…

810 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