I want to get two columns data from two tables which are not dependent to each other i.e. no key common in both they are not related to each other.

I can't use JOIN because it needs where clause which uses a common field from both tables.
I just want one column from one table and one column from another and display it.
how can do it?
some unions or any other syntax for that?

Thanks in advance,

10 Years
Discussion Span
Last Post by aardvax01
create table name1(name varchar)
insert into name1 values('A')
insert into name1 values('B')

create table name2(name varchar)
insert into name2 values('B')
insert into name2 values('C')

select name from name1
select name from name2

UNION will eliminate duplicates,If u want to retain duplicates Use UNION ALL.

Is that worked for u?If face any probs reply.


Hi Bhavna

I think that you can do it yourself
There is something called Non -Equi Joins Which needs the where clause which you want
I think you can use Logical Operators to accomplish what you want

There is one Example of Employee and Salary Tables ( a famous one)

Hope this will help you

Ok lemme give an Example -- Suppose there are two tables with name as Emp and Salary

SELECT E.Last_Name, E.Sal, S.Category
FROM Emp E, Salary S
WHERE E.Sal Between S.Highest and S.Lowest

And this example is taking oracle in consideration ..
there might be some other way of using joins in SQL Server
I will have a look and will edit this post once more

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.