| | |
Extract columns from two independent table in SQL Server 2005?
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2006
Posts: 116
Reputation:
Solved Threads: 0
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,
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,
•
•
Join Date: Mar 2008
Posts: 324
Reputation:
Solved Threads: 7
sql Syntax (Toggle Plain Text)
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 UNION 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.
Last edited by peter_budo; Apr 11th, 2008 at 7:47 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Apr 2008
Posts: 4
Reputation:
Solved Threads: 0
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
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
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
sql Syntax (Toggle Plain Text)
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
Last edited by peter_budo; Apr 17th, 2008 at 2:53 pm. Reason: Keep It Organized - please use [code] tags
•
•
Join Date: Apr 2008
Posts: 4
Reputation:
Solved Threads: 0
SQL Syntax (Toggle Plain Text)
SELECT * FROM Employees
I posted this message to learn the [code tags]
Last edited by aardvax01; Apr 18th, 2008 at 8:14 am.
![]() |
Other Threads in the MS SQL Forum
- Previous Thread: Info needed regarding SQL server 2005
- Next Thread: Error Code 424: object required
| Thread Tools | Search this Thread |





