Home All Groups Group Topic Archive Search About
Author
19 Aug 2006 10:12 PM
tom taol
table1
fld1
aa
bb
cc

table2
fld1
aa
cc

after query execute
result table1
table1
fld1
bb

"delete from table1 a where a.fld1=table2.fld1"
but not working



*** Sent via Developersdex http://www.developersdex.com ***

Author
19 Aug 2006 10:20 PM
--CELKO--
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Sample data is also a good idea, along with clear
specifications.

SELECT fld1 FROM Table1
EXCEPT
SELECT fld1 FROM Table2;
Author
19 Aug 2006 10:45 PM
Erland Sommarskog
tom taol (t**@yahoo.com) writes:
Show quote
> table1
> fld1
> aa
> bb
> cc
>
> table2
> fld1
> aa
> cc
>
> after query execute
> result table1
> table1
> fld1
> bb
>
> "delete from table1 a where a.fld1=table2.fld1"
> but not working

DELETE table1
FROM   table1 a
JOIN   table2 b ON a.fld1 = b.fld1



--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Author
19 Aug 2006 11:01 PM
Hari Prasad
Hi,

Looks like you are using SQL Server 2005.
In SQL Server 2005, the join is accomplished using the ANSI JOIN SQL syntax
(based on ANSI Standard SQL-92), which uses the JOIN keyword and an ON
clause. The ANSI JOIN syntax requires the use of an ON clause for specifying
how the tables are related. One ON clause is used for each pair of tables
being joined. The general form of the ANSI JOIN SQL syntax is:

SELECT columns
FROM table1 JOIN table2
ON table1.column1=table2.column1
Show quote
ThanksHariSQL Server MVP"tom taol" <t**@yahoo.com> wrote in message
news:O8G7Ly9wGHA.4752@TK2MSFTNGP02.phx.gbl...
>
> table1
> fld1
> aa
> bb
> cc
>
> table2
> fld1
> aa
> cc
>
> after query execute
> result table1
> table1
> fld1
> bb
>
> "delete from table1 a where a.fld1=table2.fld1"
> but not working
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***

AddThis Social Bookmark Button