清晓(332522093) 10:20:59
SELECT NoteBookID, StartID, EndID, Remark, NoteBookState,
(SELECT OrgID
FROM dbo.ST_NoteBookGet AS b
WHERE (NoteBookID = a.NoteBookID)) AS OrgID,
(SELECT OrgName
FROM dbo.ST_NoteBookGet AS b
WHERE (NoteBookID = a.NoteBookID)) AS OrgName,
(SELECT UserName
FROM dbo.ST_NoteBookGet AS b
WHERE (NoteBookID = a.NoteBookID)) AS UserName,
(SELECT OrgGetDate
FROM dbo.ST_NoteBookGet AS b
WHERE (NoteBookID = a.NoteBookID)) AS OrgGetDate
FROM dbo.ST_NoteBook AS a
|
清晓(332522093) 10:21:11
这个sql能优化吗?
|
|
清晓(332522093) 10:26:21
嗯,谢谢啊
|
[重庆]版主-Eagle(838010363) 10:28:15
select a.NoteBookID, a.StartID, a.EndID, a.Remark, a.NoteBookState,b.OrgID as OrgID,b.OrgName as OrgName, b.UserName as UserName b.OrgGetDate as OrgGetDate from dbo.ST_NoteBook as a,dbo.ST_NoteBook as b where a.NoteBookID=b.NoteBookID
|
[重庆]版主-Eagle(838010363) 10:28:22
语句给你写好了
|
[重庆]版主-Eagle(838010363) 10:28:47
fuck,写语句的时候就看到苏飞童鞋在回话了
|
[重庆]版主-Eagle(838010363) 10:31:27
select
a.NoteBookID, a.StartID, a.EndID, a.Remark,a.NoteBookState,
b.OrgID as OrgID,b.OrgName as OrgName, b.UserName as UserName b.OrgGetDate as OrgGetDate
from
dbo.ST_NoteBook as a,dbo.ST_NoteBook as b
where
a.NoteBookID=b.NoteBookID
|
Kaelthas<gexiaoliang@vip.qq.com> 10:40:49
SELECT
NoteBookID,
StartID,
EndID,
Remark,
NoteBookState,
OrgID,
OrgName,
UserName,
OrgGetDate,
FROM
ST_NoteBook
LEFT JOIN
ST_NoteBookGet
ON
ST_NoteBook.NoteBookID = ST_NoteBookGet.NoteBookID
|
|
[重庆]版主-Eagle(838010363) 10:42:01
这个是必须的,这个是正解
|
[重庆]版主-Eagle(838010363) 10:42:07
刚才看成一张表了
|
[重庆]版主-Eagle(838010363) 10:42:24
还以为是内部数据复合查询呢
|
|
[重庆]版主-Eagle(838010363) 10:44:11
@Kaelthas 问一个详细的问题
|
|
[重庆]版主-Eagle(838010363) 10:45:12
@Kaelthas 用join的这种方法 和 where 这种方法哪种节约数据库资源?
|
|
|
[重庆]版主-Eagle(838010363) 10:46:51
join 是连接2张表撒
where 是通过条件连接2张表撒
哪种对数据库的资源消耗少些
|
|
[重庆]版主-Eagle(838010363) 10:47:45
这个建议去测试一下
|
|