Question

can i join between two sql satatmnet example

select ID, NAME from tab1;
12|blabla

and

Select DESC from tab2;
vvvvvv

I want to display to

12|blabla|vvvvvv  

I was try the the UNION

select ID, NAME from tab1;
UNION 
Select DESC from tab2;

but the result was

12|blabla
12|vvvvv

any help !!

Was it helpful?

Solution

You could do this:

select t1.*, t2.*
from (select ID, NAME from tab1) t1 cross join
     (Select "DESC" from tab2) t2;

DESC is a SQL reserved word, so you need to escape it. Double quotes are one way of doing that.

OTHER TIPS

Dont use UNION but instead use JOIN

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top