select user_score from user_score where user_id in (select user_id from add_score)
语法大概是这样没问题
还不明白的Q我373866958
SELECT SNO,SNAME FROM STUDENT WHERE SAGE>18
18上面可能要加引号
SELECT SNO,SNAME FROM COURSE WHERE CCREDIT>85
85上面也坑要加引号
SELECT SNO,SNAME FROM STUDENT WHERE STUDENTSNO=(SELECT SCSNO FROM SC WHERE CNO=(SELECT CNO FROM COURSE WHERE TEACHER=‘王’))
SELECT SNO,SNAME FROM STUDENT INNER JOIN SC ON SCSNO=STUDENTSNO INNER JOIN COURSE ON SCCNO=COURSECNO WHERE COURSETEACHER='王‘
SQL:
select
into
b
from
a
where
1<>1说明:拷贝表(拷贝数据,源表名:a
目标表名:b)以下是代码片段:
SQL:
insert
into
b(a,
b,
c)
select
d,e,f
from
b;说明:显示文章、提交人和最后回复时间以下是代码片段:
SQL:
select
atitle,ausername,badddate
from
table
a,(select
max(adddate)
adddate
from
table
where
tabletitle=atitle)
b说明:外连接查询(表名1:a
表名2:b)以下是代码片段:
SQL:
select
aa,
ab,
ac,
bc,
bd,
bf
from
a
LEFT
OUT
JOIN
b
ON
aa
=
bc说明:日程安排提前五分钟提醒以下是代码片段:
SQL:
select
from
日程安排
where
datediff(’minute’,f开始时间,getdate())>5
说明:两张关联表,删除主表中已经在副表中没有的信息
SQL:
以下是代码片段:
delete
from
info
where
not
exists
(
select
from
infobz
where
infoinfid=infobzinfid 说明:--
SQL:
以下是代码片段:
SELECT
ANUM,
ANAME,
BUPD_DATE,
BPREV_UPD_DATE
FROM
TABLE1,
(SELECT
XNUM,
XUPD_DATE,
YUPD_DATE
PREV_UPD_DATE
FROM
(SELECT
NUM,
UPD_DATE,
INBOUND_QTY,
STOCK_ONHAND
FROM
TABLE2
WHERE
TO_CHAR(UPD_DATE,’YYYY/MM’)
=
TO_CHAR(SYSDATE,
’YYYY/MM’))
X,
(SELECT
NUM,
UPD_DATE,
STOCK_ONHAND
FROM
TABLE2
WHERE
TO_CHAR(UPD_DATE,’YYYY/MM’)
=
TO_CHAR(TO_DATE(TO_CHAR(SYSDATE,
’YYYY/MM’)
¦¦
’/01’,’YYYY/MM/DD’)
-
1,
’YYYY/MM’)
Y,
WHERE
XNUM
=
YNUM
(+)
AND
XINBOUND_QTY
+
NVL(YSTOCK_ONHAND,0)
<>
XSTOCK_ONHAND
B
WHERE
ANUM
=
BNUM说明:--
SQL:
以下是代码片段:
select
from
studentinfo
where
not
exists(select
from
student
where
studentinfoid=studentid)
and
系名称=’"&strdepartmentname&"’
and
专业名称=’"&strprofessionname&"’
order
by
性别,生源地,高考总成绩说明:
从数据库中去一年的各单位电话费统计(电话费定额贺电化肥清单两个表来源)
SQL:
以下是代码片段:
SELECT
auserper,
atel,
astandfee,
TO_CHAR(atelfeedate,
’yyyy’)
AS
telyear,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’01’,
afactration))
AS
JAN,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’02’,
afactration))
AS
FRI,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’03’,
afactration))
AS
MAR,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’04’,
afactration))
AS
APR,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’05’,
afactration))
AS
MAY,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’06’,
afactration))
AS
JUE,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’07’,
afactration))
AS
JUL,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’08’,
afactration))
AS
AGU,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’09’,
afactration))
AS
SEP,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’10’,
afactration))
AS
OCT,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’11’,
afactration))
AS
NOV,
SUM(decode(TO_CHAR(atelfeedate,
’mm’),
’12’,
afactration))
AS
DEC
FROM
(SELECT
auserper,
atel,
astandfee,
btelfeedate,
bfactration
FROM
TELFEESTAND
a,
TELFEE
b
WHERE
atel
=
btelfax)
a
GROUP
BY
auserper,
atel,
astandfee,
TO_CHAR(atelfeedate,
’yyyy’)说明:四表联查问题:SQL:
以下是代码片段:
select
from
a
left
inner
join
b
on
aa=bb
right
inner
join
c
on
aa=cc
inner
join
d
on
aa=dd
where
说明:得到表中最小的未使用的ID号
SQL:
以下是代码片段:
SELECT
(CASE
WHEN
EXISTS(SELECT
FROM
Handle
b
WHERE
bHandleID
=
1)
THEN
MIN(HandleID)
+
1
ELSE
1
END)
as
HandleID
FROM
Handle
WHERE
NOT
HandleID
IN
(SELECT
aHandleID
-
1
FROM
Handle
a)
以上就是关于数据库select语句全部的内容,包括:数据库select语句、数据库设计的SELECT语句、SQL Select 语句的用法等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)