Can any one tell me result in this delete statement | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

Can any one tell me result in this delete statement

I have a table called table1 contains id column values like 1 to 10, another table table2 contain iid column values like 5 to 15 now my query is delete from table1 where id in(select id from table2) so what is the out come of this query thanks in advance

17th Jul 2016, 4:24 PM
ashwath nm
ashwath nm - avatar
8 ответов
+ 1
ok i will share answer first the error, table2 doesn't have id column table2 has iid column, but when you run this query in sql server you can't get the error because sql ignores sub query error and executes the query successfully but result is table1 rows will Delete entirely not from rows id 5 to 10 thanks for the answers
19th Jul 2016, 3:10 AM
ashwath nm
ashwath nm - avatar
0
from table1 rows from ID 5 to 10 will be deleted
17th Jul 2016, 5:44 PM
Rahul
Rahul - avatar
0
sorry your answer is wrong please re read the question exactly as it is and try again
17th Jul 2016, 6:47 PM
ashwath nm
ashwath nm - avatar
0
hello @ manasa please run the script as it is and create table exactly as in the question and tell me the answer I know the answer exactly because I did it that's why and before down vote any answers make sure you know perfect result
18th Jul 2016, 2:40 PM
ashwath nm
ashwath nm - avatar
0
there is an error in the query but we can't get error in SQL express, SQL ignores the error and executes the query this is an hint because you guys don't know how to read question exactly as it is.
18th Jul 2016, 2:43 PM
ashwath nm
ashwath nm - avatar
0
@manasa I didn't edited question that's why I keep telling from beginning read question exactly as it is. and as our mind set we skip extra "I" and we read just id, I did this wrong query in a live database more than 2000 data has lost so then only I found the error that's why I posted here so if any one thinks this is useful then they don't make the error as I did
21st Jul 2016, 5:27 AM
ashwath nm
ashwath nm - avatar
0
for general info before you write delete query first write select then change it to delete so u can know exactly what data is going to delete ex: select * from table where obtainmarks >59 execute it and then change it to delete from table where obtainmarks >59 now u know which data is going to delete for sure
21st Jul 2016, 5:38 AM
ashwath nm
ashwath nm - avatar
0
id's from 5 to 10 r deleted
17th Sep 2016, 5:17 PM
Raghavendra