exists - What is the different between the two sql codes? -
1.
Define course_id where it exists (choose course_id from course where course_id no (choose course_id from section);); 2.
Define course_id where course_id is not (choose course_id from the section); I want to get the course in every course_id table which does not appear in the table section . First result in 200; Second result in 115 Why is the result of both of them different? I first explain that I will check whether course_id has no course related to section if Is present, return course_id , which is selected as course_id
From the docs:
If a subquery returns a line at all, the current subcategory is true, and currently it is not subquery is FALSE In your case, 1 query sums up all the rows It looks like
select course_id from the course where TRUE; So if you want to retrieve every course_id in the table course that does not appear in the table section then your second query is correct.
And about this:
I first explain that I definitely check whether or not I'm sure that the course_id is not in that section. If present, then course_id is correct, which is the first course_id selected.
This is an incorrect interpretation:
Comments
Post a Comment