sql server 2008 - How to select a column from one table and two columns from another table when both the tables have no relation in T-SQL? -
i explain problem simple possible.
have written select query query1
on table1
gives me following result
select * table1 typeid=1
id column1 column2 typeid
1 a 1
2 b b 1
3 c c 1
i have table table2
has data in following format
id column1 column2
1 0 0
1 1 1
2 2 2
2 3 3
2 4 4
3 5 5
3 6 6
i have written select query query2
on table1
gives me following result
select * table1 typeid=2
id column1 column2 typeid
4 a 2
5 b b 2
6 c c 2
table1
, table2
have no column in common , data in column1
, column2
both typeid's
in table1
same , data in table2
has data values of id
column table1
id's 1,2,3 , want write select query select same data table2
values of id
column table1
typeid
2 have given below
id column1 column2
4 0 0
4 1 1
5 2 2
5 3 3
5 4 4
6 5 5
6 6 6
how can achieve writing select query in sql server?
select t1.column1, isnull(t2.column2,0) column2, isnull(t2.column3,0) column3 table1 t1 left outer join on table2 t2 on t1.column9=t2.column9 ....
Comments
Post a Comment