SQL 查询相关数据

来源:百度知道 编辑:UC知道 时间:2024/05/02 16:57:57
问题如下
TABLE:电影
NAME,LENGTH
good 10
bad 20
time 10
ok 20
bye 30
问题是我要选出只有 LENGTH 相同的 NAME
答案是 good time ok bad
求解答

根据 whyang2006 - 经理 四级 的回答修改

select first.name,second.name
from 电影 first,电影 second
where first.length=second.length
and first.name<>second.name

select first.name,second.name
from 电影 first,电影 second
where first.length=second.length

这句会实现你说效果
select name from 电影 where length = 10

http://zhidao.baidu.com/question/72415185.html
不是回答过了吗 不行吗

select distinct t1.NAME from 电影 as t1 ,电影 as t2
where t1.LENGTH = t2.LENGTH and t1.NAME<>T2.NAME

我还想在问一下是不是LENGTH相等的最多只有2条记录
如果不是 比如再加一条 test 10 楼上的SQL运行下试试看结果怎么样

select A.name
from 电影 A,电影 B
where A.length=B.length

select * from 电影
where length=10 and length=20;