sql - Join two tables on a column mix with ids and space -


how write sql statement in sql server 2008r2 join 2 tables on column has space? getting error "error converting data type varchar numeric."

e.g. table1

[id | value | t2id]   1 |     |  1   2 |   b   |     3 |   c   |  2 

table2

[id | value]   1 |   d   2 |   e   3 |   f 

result

[id | value | t2id | id | value]   1 |     |  1   |  1 |   d   2 |   b   |      |null| null   3 |   c   |  2   |  2 |   e 

it left join show values table1, t2id column has ids table2 , spaces. joining 2 tables directly gave me above error.

thank you

you can use following query -

select *   table1, table2  table1.t2id = table2.id    , table1.t2id not null union select table1.*, null, null table1 table1.t2id null 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -