What is the expected output of below SQL

SELECT DeptNo FROM dept_tbl UNION ALL SELECT DeptNo FROM dept_master;

Table Dept _tbl

Dept No

Depart Name

10

Accounting

20

Purchase

30

Sales

50

Marketing

Table Dept_master

DeptNo

DepartName

10

Accounting

20

Purchase

30

Sales

40

Stores

DeptNo---------1010202030304050

DeptNo---------1020304050

DeptNo---------10203040

DeptNo---------10203050

Verified Answer
Correct Option - a
Anush said

The expected output of the SQL query is:

10

20

30

50

10

20

30

40

The UNION ALL operator combines the result sets of both SELECT statements, including duplicates. So, you'll see all the DeptNo values from both tables, with duplicates included.

If you want to remove duplicates, you can use the UNION operator instead of UNION ALL:

SELECT DeptNo FROM dept_tbl UNION SELECT DeptNo FROM dept_master;

This will give you:

10

20

30

40

50

To get all Infosys Certified MySQL Associate Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in