急求一段SQL语句

soho00222 2004-08-10 10:10:47
两个表A和B,A表ID字段和B表product_id字段相关联

我想查询以下内容
查询A表中的记录,条件如下,B表product_id字段没有A表的ID字段记录
...全文
171 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
soho00222 2004-08-10
  • 打赏
  • 举报
回复
我晕,一下子就这么回复
mind_1220 2004-08-10
  • 打赏
  • 举报
回复
恐怕楼上的把题目看错了吧?
ycted 2004-08-10
  • 打赏
  • 举报
回复
写错了,应该是select * from A a,B b where a.id=b.product_id
ycted 2004-08-10
  • 打赏
  • 举报
回复
select * from A a,B a where a.id=b.product_id
sunjiujiu 2004-08-10
  • 打赏
  • 举报
回复
楼上的很多方法都可行
BubbleInDiamond 2004-08-10
  • 打赏
  • 举报
回复
哈哈,提一个问题可以有这么多错误答案,真是好!获得不少经验(怎么才不会写错)
mind_1220 2004-08-10
  • 打赏
  • 举报
回复
我刚才写错了一点哈

select * from b where Product not exist(select id from a)
skyboy0720 2004-08-10
  • 打赏
  • 举报
回复
select * from 表A where id not exists(select product_id from 表B )
mind_1220 2004-08-10
  • 打赏
  • 举报
回复
select product_id from b where not exist(select id from a)
银狐被占用 2004-08-10
  • 打赏
  • 举报
回复
上面写错了。

select * from A where ID in (select * from B where product_id not in (select ID from A))
flyskywlh 2004-08-10
  • 打赏
  • 举报
回复
select * from A where id not in(select product_id from B)
凯晰叶子 2004-08-10
  • 打赏
  • 举报
回复
你要自己编写程序添加的呀!又不是建好关系就可以自动更新的!

添加数据时你两个表都要A添加的ID号添加到B表中的product_id,读取时也要设计两个表同时打开的!
银狐被占用 2004-08-10
  • 打赏
  • 举报
回复
select * from B where product_id not in (select ID from A)

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧