{"id":23076,"date":"2013-05-13T15:00:52","date_gmt":"2013-05-13T09:30:52","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=23076"},"modified":"2024-04-12T14:23:39","modified_gmt":"2024-04-12T08:53:39","slug":"exists-intersect-and-except-operator","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/","title":{"rendered":"EXISTS, INTERSECT and EXCEPT operator"},"content":{"rendered":"\n<p><strong>EXISTS, INTERSECT and EXCEPT operator<\/strong><\/p>\n\n\n\n<p>In SQL Server 2008, there are several operators that can be used to manipulate data. Three of the most commonly used operators are EXISTS, INTERSECT, and EXCEPT.<\/p>\n\n\n\n<p>EXISTS operator:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\" start=\"1\">\n<li>The EXISTS operator is used to check whether a subquery returns any rows. It returns true if the subquery returns at least one row, and false otherwise. The EXISTS operator is typically used in a WHERE clause to filter rows based on the result of a subquery. For example, if you wanted to find all customers who have placed an order, you could use the following SQL statement:<\/li>\n<\/ol>\n\n\n\n<p>SELECT * FROM Customers WHERE EXISTS (SELECT * FROM Orders WHERE Orders.CustomerID = Customers.CustomerID)<\/p>\n\n\n\n<p>INTERSECT operator:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The INTERSECT operator is used to return the common rows from two or more SELECT statements. It compares the result sets of two or more SELECT statements and returns only the rows that appear in all of the result sets. For example, if you wanted to find all customers who have placed an order and also have a shipping address in New York, you could use the following SQL statement:<\/li>\n<\/ul>\n\n\n\n<p>SELECT * FROM Customers WHERE EXISTS (SELECT * FROM Orders WHERE Orders.CustomerID = Customers.CustomerID)<\/p>\n\n\n\n<p>INTERSECT<\/p>\n\n\n\n<p>SELECT * FROM Customers WHERE City = &#8216;New York&#8217;<\/p>\n\n\n\n<p>EXCEPT operator:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The EXCEPT operator is used to return the rows that appear in the first SELECT statement but not in the second SELECT statement. It compares the result sets of two SELECT statements and returns only the rows that are unique to the first SELECT statement. For example, if you wanted to find all customers who have placed an order but have not yet paid for it, you could use the following SQL statement:<\/li>\n<\/ul>\n\n\n\n<p>SELECT * FROM Orders WHERE NOT EXISTS (SELECT * FROM Payments WHERE Payments.OrderID = Orders.OrderID)<\/p>\n\n\n\n<p>EXCEPT<\/p>\n\n\n\n<p>SELECT * FROM Orders WHERE Paid = 1 These operators are very useful in manipulating data and allow for complex queries to be written in a concise and efficient manner.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Apply for SQL Server 2008 Certification!!<\/strong><\/h3>\n\n\n\n<p><a href=\"https:\/\/www.vskills.in\/certification\/certified-sql-server-2008-programmer\">https:\/\/www.vskills.in\/certification\/certified-sql-server-2008-programmer<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/sql-server-2008-programmer\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Back to Tutorials<\/strong><\/a><\/h4>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>EXISTS, INTERSECT and EXCEPT operator In SQL Server 2008, there are several operators that can be used to manipulate data. Three of the most commonly used operators are EXISTS, INTERSECT, and EXCEPT. EXISTS operator: SELECT * FROM Customers WHERE EXISTS (SELECT * FROM Orders WHERE Orders.CustomerID = Customers.CustomerID) INTERSECT operator: SELECT * FROM Customers WHERE&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[322],"tags":[],"class_list":["post-23076","page","type-page","status-publish","hentry","category-sql-server-2008"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>EXISTS, INTERSECT and EXCEPT operator Tutorials<\/title>\n<meta name=\"description\" content=\"EXISTS, INTERSECT and EXCEPT operator Tutorials\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"EXISTS, INTERSECT and EXCEPT operator Tutorials\" \/>\n<meta property=\"og:description\" content=\"EXISTS, INTERSECT and EXCEPT operator Tutorials\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:53:39+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/\",\"name\":\"EXISTS, INTERSECT and EXCEPT operator Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2013-05-13T09:30:52+00:00\",\"dateModified\":\"2024-04-12T08:53:39+00:00\",\"description\":\"EXISTS, INTERSECT and EXCEPT operator Tutorials\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"EXISTS, INTERSECT and EXCEPT operator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"EXISTS, INTERSECT and EXCEPT operator Tutorials","description":"EXISTS, INTERSECT and EXCEPT operator Tutorials","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/","og_locale":"en_US","og_type":"article","og_title":"EXISTS, INTERSECT and EXCEPT operator Tutorials","og_description":"EXISTS, INTERSECT and EXCEPT operator Tutorials","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:53:39+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/","name":"EXISTS, INTERSECT and EXCEPT operator Tutorials","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2013-05-13T09:30:52+00:00","dateModified":"2024-04-12T08:53:39+00:00","description":"EXISTS, INTERSECT and EXCEPT operator Tutorials","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/exists-intersect-and-except-operator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"EXISTS, INTERSECT and EXCEPT operator"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/23076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=23076"}],"version-history":[{"count":6,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/23076\/revisions"}],"predecessor-version":[{"id":133840,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/23076\/revisions\/133840"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=23076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=23076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=23076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}