{"id":223745,"date":"2025-06-02T10:03:23","date_gmt":"2025-06-02T10:03:23","guid":{"rendered":"https:\/\/learnexams.com\/blog\/?p=223745"},"modified":"2025-06-02T10:12:11","modified_gmt":"2025-06-02T10:12:11","slug":"refer-to-the-tables","status":"publish","type":"post","link":"https:\/\/www.learnexams.com\/blog\/2025\/06\/02\/refer-to-the-tables\/","title":{"rendered":"Refer to the tables."},"content":{"rendered":"\n<p>Refer to the tables. Which products are selected by the query below? <\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/learnexams.com\/blog\/wp-content\/uploads\/2025\/06\/image-13.png\" alt=\"\" class=\"wp-image-223746\"\/><\/figure>\n\n\n\n<p><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-ast-global-color-0-color\">The Correct Answer and Explanation is:<\/mark><\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 Correct Answer:<\/h3>\n\n\n\n<p><strong>Onesies set, Sunsuit, Romper<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udcd8 Explanation:<\/h3>\n\n\n\n<p>The SQL query provided is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT ProductName\nFROM Product\nWHERE SupplierId IN (\n    SELECT SupplierId\n    FROM Supplier\n    WHERE CountryId = 2\n);\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\ud83d\udd0d Step-by-step Breakdown:<\/h4>\n\n\n\n<p><strong>1. Understand the Subquery:<\/strong><br>The subquery:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT SupplierId FROM Supplier WHERE CountryId = 2\n<\/code><\/pre>\n\n\n\n<p>will return all <code>SupplierId<\/code>s where the <code>CountryId<\/code> is <strong>2<\/strong>.<br>Looking at the <code>Supplier<\/code> table, the suppliers from <code>CountryId = 2<\/code> are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>SupplierID = 2 (Oshkosh Bgosh)<\/li>\n\n\n\n<li>SupplierID = 4 (SugarPlum)<\/li>\n\n\n\n<li>SupplierID = 5 (Rosebuds for Girls)<\/li>\n\n\n\n<li>SupplierID = 7 (Periwinkle)<\/li>\n<\/ul>\n\n\n\n<p>So, the result of the subquery is:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>2, 4, 5, 7\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>2. Apply the Result to the Main Query:<\/strong><\/p>\n\n\n\n<p>Now, look at the <code>Product<\/code> table and select rows where <code>SupplierId<\/code> is <strong>IN (2, 4, 5, 7)<\/strong>.<\/p>\n\n\n\n<p>From the <code>Product<\/code> table:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>ProductName<\/th><th>SupplierId<\/th><\/tr><\/thead><tbody><tr><td>Onesies set<\/td><td>2<\/td><\/tr><tr><td>Sunsuit<\/td><td>2<\/td><\/tr><tr><td>Romper<\/td><td>4<\/td><\/tr><tr><td>Pajama set<\/td><td>3 \u274c<\/td><\/tr><tr><td>Shorts set<\/td><td>3 \u274c<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>So, only the following products have SupplierId in (2, 4, 5, 7):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Onesies set (SupplierId 2)<\/li>\n\n\n\n<li>Sunsuit (SupplierId 2)<\/li>\n\n\n\n<li>Romper (SupplierId 4)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>3. Final Answer:<\/strong><br>\u2705 <strong>Onesies set, Sunsuit, Romper<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83d\udccc Summary:<\/h3>\n\n\n\n<p>The query filters all products whose supplier is located in a country with <code>CountryId = 2<\/code>. By checking the supplier IDs that meet this criterion and matching them to the products, we accurately retrieve the names of the products supplied by those vendors. This is a classic example of using a subquery to filter a parent table using a foreign key relationship.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/learnexams.com\/blog\/wp-content\/uploads\/2025\/06\/learnexams-banner5-20.jpeg\" alt=\"\" class=\"wp-image-223747\"\/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Refer to the tables. Which products are selected by the query below? The Correct Answer and Explanation is: \u2705 Correct Answer: Onesies set, Sunsuit, Romper \ud83d\udcd8 Explanation: The SQL query provided is: \ud83d\udd0d Step-by-step Breakdown: 1. Understand the Subquery:The subquery: will return all SupplierIds where the CountryId is 2.Looking at the Supplier table, the suppliers [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[25],"tags":[],"class_list":["post-223745","post","type-post","status-publish","format-standard","hentry","category-exams-certification"],"_links":{"self":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/223745","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/comments?post=223745"}],"version-history":[{"count":0,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/posts\/223745\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/media?parent=223745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/categories?post=223745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.learnexams.com\/blog\/wp-json\/wp\/v2\/tags?post=223745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}