我有一个内部查询
select * from ASSETVERSION where id in (
select ASSETVERSION_ID from scene_asset where scene_id in(
select scene_id from contentobject_scene where contentobject_id in(
select id from contentobject where course_id = 34660
)
)
)
and LOCATION is not null
当我运行此查询时,我得到 27 条记录。现在我将此查询转换为连接,例如
select av.* from ASSETVERSION av
inner join scene_asset sa on av.id = sa.assetversion_id
inner join scene s on s.id = sa.scene_id
inner join contentobject_scene co_s on s.id = co_s.scene_id
inner join contentobject co on co.id = co_s.contentobject_id
inner join course c on c.id = co.course_id
where
c.id = 34660
and av.location is not null
当我运行此查询时,我得到 36 条记录。当我从 更改为av.*
时distinct av.*
,我得到 27 条记录作为内部查询返回。
当我从 更改为distinct av.*
时distinct av.id, av.asset_id, av.location, co.name as "Content Object name", s.name as "Scene Name" from ASSETVERSION av
,我再次获得 36 条记录。
distinct av.id, av.asset_id, av.location --, co.name as "Content Object name", s.name as "Scene Name" from ASSETVERSION av
工作正常。平均返回 27 条记录。
有什么办法我可以应用不同的co.name as "Content Object name", s.name as "Scene Name"
喜欢
select distinct av.id, av.asset_id, av.location, distinct co.name as "Content Object name", distinct s.name as "Scene Name"
from ASSETVERSION av ...
所以我得到与内部查询返回的相同的 27 条记录?
谢谢