Database & SQL

Moderators: None (Apply to moderate this forum)
Number of threads: 1194
Number of posts: 2247

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Update Query Help... Posted by oip on 24 Sept 2004 at 10:39 AM
Greets,

Have a (hopefully) quick question.

How do I UPDATE one table based on criteria in another table?

All help will be greatly appreciated.

Thanks in advance.

Report
Re: Update Query Help... Posted by infidel on 27 Sept 2004 at 8:13 AM
: Greets,
:
: Have a (hopefully) quick question.
:
: How do I UPDATE one table based on criteria in another table?
:
: All help will be greatly appreciated.

Depends on what you want to do.

update table1 set
column1 = (select sum(column4) from table2)


update table1 t1 set
column1 = value1
where exists (
    select 1 from table2 t2
    where t1.column3 = t2.column1
    and ...
)


If you'd be more specific I might be able to give you a better example.


infidel

$ select * from users where clue > 0
no rows returned





 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.