Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
mistylove98
Starting Member
5 Posts |
Posted - 2015-04-28 : 18:12:30
|
I have to write a delete statement that deletes all customers that have not put in an order I must use a subquery in the exist operator can someone point me in the right direction? thanks
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-04-28 : 18:16:04
|
Here's an example: DELETE t1 FROM t1 WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE t1.c1 = t2.c1)
Tara Kizer SQL Server MVP since 2007 http://weblogs.sqlteam.com/tarad/ |
 |
|
mistylove98
Starting Member
5 Posts |
Posted - 2015-04-28 : 18:46:38
|
this is what i tried but it is wrong
delete customers from dbo.customers WHERE (customerID NOT exist (SELECT customerID FROM dbo.Orders)) |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-04-28 : 19:24:45
|
Please see my example. Your syntax doesn't match.
Tara Kizer SQL Server MVP since 2007 http://weblogs.sqlteam.com/tarad/ |
 |
|
susheel123
Starting Member
1 Post |
Posted - 2015-04-29 : 01:57:13
|
Sir,,,I was trying to copy one column of one table to another table.....below is the query
Insert into sak_tst_student_sports_detail(stud_fname) select stud_fname from sak_tst_student_detail;
still not getting answer..please reply |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-04-29 : 12:03:35
|
quote: Originally posted by susheel123
Sir,,,I was trying to copy one column of one table to another table.....below is the query
Insert into sak_tst_student_sports_detail(stud_fname) select stud_fname from sak_tst_student_detail;
still not getting answer..please reply
First, I'm not a sir. Second, don't hijack threads. Post your question in a new topic.
Tara Kizer SQL Server MVP since 2007 http://weblogs.sqlteam.com/tarad/ |
 |
|
|
|
|