Select 1 from dualunionselect 'A' from dual; I guess the query will select zero rows. Is it wrong or right ? if wrong thenWhat will be the result set for the query?Thanks in advance.

Showing Answers 1 - 6 of 6 Answers

Ashish

  • Feb 23rd, 2006
 

The query would throw an error.

The two data types in the union set should be same.

Out here it is a 1 and  'A', datatype mismatch and hence the error.

  Was this answer useful?  Yes

nileshsingh

  • May 19th, 2006
 

The datatype should be same,if we are using UNION set operator

on executing this statement

Select 1 from dual
union
select 'A' from dual;

we will get the following error on the prompt:

expression must have same datatype as corresponding expression

  Was this answer useful?  Yes

Renuka Rajput

  • Jul 29th, 2006
 

i would like to add one more point that not only datatypes but also structure of both the select statement should be same.

if we write query as

select 1,2 from dual

union

select 1 from dual

it will still results in error and the error is

expression must have same datatype as corresponding expression

  Was this answer useful?  Yes

nis1981

  • Aug 3rd, 2008
 

Inorder to use UNION SET OPERATOR the datatype and the number of columns should match. Here you are trying to get the union of a character datatype and a number, hence you get an error.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions