我是 SQL Server 的新手,我正在尝试通过它们的名称和类型(CD/DVD)搜索一些 CD 或 DVD。
如果没有解决,我想显示我库存中的 CD 或 DVD 数量。
DECLARE @typ VARCHAR
SET @name = 'Kil'
SET @typ = 'DVD'
IF (@typ like 'DVD')
begin
select titul.name from titul
where titul_id in (
select titul_id from dvd
where titul_id in (
select titul_id
from titul
where titul.name like @name+'%'
)
and (dvd.soldDate is NULL)
)
group by titul.name
end
但第一步(如果 DVD ..)不起作用。