求数据库查询语句
现在有表TABLE1 && TABLE2
TABLE1
masID WireID Description
1 5 hello
2 2 good
3 0 input
TABLE2
WireID UP Down
5 newup newdown
2 oldup olddown
需要生成集合如下,请知道的同志指点.谢谢啦!
masID up down description
1 newup newdown hello
2 oldup olddown good
3 " " " " input
[解决办法]
1 如果不管空值的话:
select table1.masid,table2.up,table2.down,table1.description
from table1 left join table2
on table1.wireid=table2.wireid
order by table1.masid
2 如果想把空值替换一下的话
select table1.masid,isnull(table2.up, '_ '),isnull(table2.down, '_ '),table1.description from table1 left join table2
on table1.wireid=table2.wireid
order by table1.masid