select a.*,b.* from a,b where a.item = b.item
解决方案 »
- 求高手指导如何平均分配金额
- 外网访问局域网的数据库
- 请教一个重建数据库的问题`急``
- sql 语句
- [Microsoft][ODBC SQL Server Driver][SQL Server]将varchar值'一等船长'转换为数据类型为int的列时发生语法错误。
- 我的表中一个字段设置成了vachar,长度为1000,用来存放描述信息, 这样好吗?
- 如何在ODBC中配置一个SQLSERVER的数据源?
- 在对表做操作的时候,数据库会自动锁表,,是吗??
- VFP GRID表示计算结果字段问题,求教?
- 请用SQL语言写出下列两个查询:
- 数据库容量问题
- 怎样导入Access数据库而保全它所有的数据包括完整性
我的前提是要保留A表里所有记录,再和B表做连接查询
ITEM ITEM_DESC ITEM STK
555 123 557 15
556 224 558 16
557 336
558 156
我想要得到的结果是
ITEM ITEM_DESC STK
555 123 NULL
556 224 NULL
557 336 15
558 156 16
如果按楼上所写,只有最后两条记录了
这个肯定是正确地!我刚测试了
本来left join就是取左表的记录(包括右表中没有的)
right join正好相反!
from a left join b on a.item = b.item
create table a (item int,item_Desc nvarchar(1000))insert into a
select 555,'123'
union all
select 556,'224'
union all
select 557,'336'
union all
select 558,'156'create table b (item int, stk int)insert into b
select 557,15
union
select 558,16select a.*,b.stk from a left join b on a.item = b.item
555 123 NULL
556 224 NULL
557 336 15
558 156 16