怎么用SQL语句表达 A÷B ?

samansakk 2005-04-26 09:24:34
假设有两表 A(a,b,c) 和 B(a,b)
要求A÷B

比如
A表:
a b c
---------------
e1 f1 g1
e1 f2 g2
e2 f1 g1
e3 f2 g2

B表:
a b
---------
f1 g1
f2 g2

则A÷B的结果应为 e1

这怎么用SQL语句表达??
...全文
241 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
chiwei 2005-04-27
  • 打赏
  • 举报
回复
运算符 含义

+(加) 加法。
-(减) 减法。
*(乘) 乘法。
/(除) 除法。
%(模) 返回一个除法的整数余数。例如,12 % 5 = 2,这是因为 12 除以 5,余数为 2。

楼主是这个意思吗?

Well 2005-04-27
  • 打赏
  • 举报
回复
--建立測試環境
create table d(a varchar(50),b varchar(50),c varchar(50))
insert into d
select 'e1', 'f1', 'g1' union all
select 'e1' , 'f2' , 'g2' union all
select 'e2', 'f1' , 'g1' union all
select 'e3', 'f2', 'g2'

create table d1(a varchar(50),b varchar(50))
insert into d1
select 'f1' , 'g1' union all
select 'f2' , 'g2'

--測試
select identity(int,1,1) ID ,d.a into #t from d , d1 where d.b=d1.a and d.c=d1.b
select A.a from #t A,#t B where a.a=b.a and a.id>b.id
--刪除測試用例
drop table d
drop table d1
drop table #t
huailairen 2005-04-27
  • 打赏
  • 举报
回复

select f1.a
from f1 right outer join b1 on f1.b=b1.b and f1.c=b1.c
group by f1.a
having count(*)>((select count(*) from b1)-1)
xiaos139 2005-04-27
  • 打赏
  • 举报
回复
Select Distinct A.a From A
Where Exists
(Select * From A t1
Where A.a = t1.a
and not Exists
(Select * from B
Where a = A.b
and b = t1.c))
Well 2005-04-27
  • 打赏
  • 举报
回复
我知道樓主的意思了。
是兩個表之間進行÷運算。
chenqianlong 2005-04-27
  • 打赏
  • 举报
回复
sql 裡面的矩陣運算,學
yesyesyes 2005-04-27
  • 打赏
  • 举报
回复
楼主的意思是矩阵运算
samansakk 2005-04-26
  • 打赏
  • 举报
回复
再顶下先 :)
samansakk 2005-04-26
  • 打赏
  • 举报
回复

就是 那种用 ∏...那种选择,投影有讲到 除的操作啊

关系代数的4个组合操作--- 交,连接,自然连接,除法

是我学SQL语言前,看的一些关系代数运算,里面就一个除法,老是不知道怎么用SQL表示
hjw01592 2005-04-26
  • 打赏
  • 举报
回复
是哦,楼主讲明白点啊
健者天行 2005-04-26
  • 打赏
  • 举报
回复
没看明白,UP
samansakk 2005-04-26
  • 打赏
  • 举报
回复
怎么没人回 55555~~

upupup

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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