MySQL UNION
- Which keyword used with UNION retains duplicate rows?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
The keyword ‘ALL’ used along with ‘UNION’ is not synonymous with just the ‘UNION’ statement. It produces the duplicate rows, if they exist, from the combination of the two tables in the SELECT query.
- Which keyword used with UNION does not retain duplicate rows?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
The keyword ‘DISTINCT’ used along with ‘UNION’ is synonymous with just the ‘UNION’ statement. It produces only the distinct rows from the combination of the two tables in the SELECT query.
- The following statement is invalid.
SELECT name, id FROM table1 UNION name, def FROM table2;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: A
Even if the columns ‘id’ and ‘def’ have different data types, the results from these columns are placed into the column ‘id’. The data types can be determined from the values in the columns.
- What is ‘name’ in the following statement?
SELECT name FROM table1 UNION name FROM table2;
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
The ‘SELECT’ queries can be combined together using the ‘UNION’ operator to produce the concatenated results from two or more tables. The data type of the columns is not taken into account.
- To combine multiple retrievals, we write several SELECT statements and put the keyword between them. What is the keyword?
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
The ‘UNION’ operator is used for combining the results of various ‘SELECT’ queries into one. For example, ‘SELECT a FROM table1 UNION SELECT a FROM table2;’ produces the results from tables table1 concatenated with that of table2.