回 帖 发 新 帖 刷新版面

主题:请教一个数据库查询的问题

[url=http://upload.programfan.com/upfile/20060530121514.rar]建立数据库以及添加数据的SQL文件[/url]

1.要查询的要求是:
显示玩具的名称和所有玩具的购物车ID.如果玩具不在购物车中,则显示为空。
主要就是“如果玩具不在购物车中,则显示为空 ”,不知道怎么处理~

2.另外还有一个问题是
对Recipient表和Country表中的cCountryId属性定义一个用户自定义数据类型,并将该属性的类型定义为这个自定义数据类型。

麻烦高手帮我想想,希望和大家好好交流一下

回复列表 (共3个回复)

沙发

给出表结构,没有标结构怎么写sql?
1。如果你有两个表:t1玩具id,t2购物车id,玩具id
t1:pid
t2:bid,pid
select 'box1' bid,'p1' pid into #t1
insert #t1 select 'box1','p2'
union  all select 'box1','p3'
union  all select 'box2','p1'
select distinct pid into #t2 from #t1
insert #t2 select 'p4'
select isnull(bid,'') bid,#t2.pid from #t2 left join #t1 on #t1.pid=#t2.pid order by #t2.bid desc

板凳

t1,t2构造反了

3 楼

建立数据库以及添加数据的SQL文件
不是给了你2个建表的SQL文件了吗?
...............

我来回复

您尚未登录,请登录后再回复。点此登录或注册