I am new to SQL Server and I am trying to search some CDs or DVDs through their name and type(CD/DVD).
If they are not solved, I would like to show the amount CDs or DVDs, which I have in my stock.
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
But the first step (If DVD..) does not work.