hi friends,i have a 3 tablesitem:CREATE TABLE [dbo].[item]( [id] [int] IDENTITY(1,1) NOT NULL, [name] [nchar](10) COLLATE Arabic_CI_AS NOT NULL, [itemcategoryid] [int] NOT NULL)insert into item values ('item1','1')insert into item values ('item2','2')
itemcategoryCREATE TABLE [dbo].[itemcategory]( [id] [int] IDENTITY(1,1) NOT NULL, [name] [nchar](10) COLLATE Arabic_CI_AS NOT NULL)insert into itemcategory values ('test1')insert into itemcategory values ('test2')insert into itemcategory values ('test3')insert into itemcategory values ('test4')
and order tableCREATE TABLE [dbo].[order]( [id] [int] IDENTITY(1,1) NOT NULL, [itemid] [int] NULL, [itemcategoryid] [int] NULL)insert into [order] values('1',null)insert into order values('2',null)
when i want to insert in order table ,i want to if for itemcategoryidthat i want to insert there is not item in item table it print'yes'for example when i exec this query i wan to print no becase i don`t define item for itemcategoryid =4select count(*) from item i where i.itemcategoryid in(1,4)i dont know how do this.please help me.i need your helping.