Re: UPDATE TABLE1 ONLY WHEN ALL RECORDS IN COLUMN IN TABLE2 ARE TRUE
- From: "David Portas" <REMOVE_BEFORE_REPLYING_dportas@xxxxxxx>
- Date: 14 May 2006 08:52:01 -0700
EdwardH wrote:
Table2 has multiple records joined to single record in Table1. I want to
UPDATE column in Table1 only if all joined records in Table2 are True.
Help would much apprec.
Here's a guess. I'm assuming that "some_col" is not nullable. If you
post proper DDL for your tables then we won't have to make so many
guesses.
UPDATE table1
SET ... ??? /* unspecified */
WHERE NOT EXISTS
(SELECT *
FROM table2
WHERE table2.some_col = 'False'
AND table2.col1 = table1.col1) ;
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
.
- Prev by Date: Re: Last order date for each customer
- Next by Date: Re: select date list
- Previous by thread: Re: Last order date for each customer
- Next by thread: Re: select date list
- Index(es):
Relevant Pages
|
|