mysql - SQL Update table from not exists statement -


still new learning lots.

i have 2 tables avdmaster , avdupdates.

i update current existing row(s) in avdmaster (fields: owner, reg, previous) new data avdupdates (fields: owner, reg, previous) avdupdates reg not exist in avdmaster reg, uniqueid in both tables matches. avdmaster fair size table 860k records.

my select statement seems work, found 4 row(s) update:

select b.uniqueid, b.reg, b.previous  avdupdates b  not exists (select l.reg avdmaster l b.reg = l.reg) 

but tried update statement select, , receive #1064 error.

update avdmaster  set l.reg=b.reg, l.owner=b.owner, l.previous=b.previous  (select b.uniqueid, b.reg, bprevious `from avdupdates b not exists (select l.reg avdmaster l b.reg = l.reg)) 

hopefully 1 of sql gurus can me out update statement, , whether or not not exists best query method?

secondly, interested in similar statement insert rows avdupdates uniqueid not exist in avdmaster.

thanks,

stephen


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -