sql server - Select all columns, but perform except statement on certain columns -


i have temporary table #tempjointable

i have 2 fields in temptable called product_fam_id , product_id, , 2 fields called mandatory_cd , display_cd.

basically, have list of products stored inside temporary table. 1 of these product_fam_id/product_id combinations have been tested, rows , records product combination, '591'/'103', should exact same other combinations have stored in 'products check' temptable. thing should different product_fam_id , product_id values, of course

so tried following, i'm pretty new @ sql , bit stuck. advice @ welcome

 create table #tempproductstocheck (     productfamilyid char(10) null,     productid char(10) null )  insert #tempproductstocheck (productfamilyid, productid) values ('591', '98'), ('591', '99'), ('591', '101'), ('591', '102'), ('502', '101'), ('502', '102'), ('591', '100'), ('591', '103'), ('502', '103') 

the main #tempjointable consists of product fields, , mandatory_cd, , display_cd

select distinct * #tempjointable (product_family_id, product_id) in (select product_family_id, product_id                                           #tempproductstocheck) , exists (select distinct mandatory_cd, display_cd #tempjointable)  except  select distinct * #tempjointable (product_family_id, product_id) in ('591', '103') , exists (select distinct mandatory_cd, display_cd #tempjointable) 

i think done enough if wanted return mandatory_cd , display_cd fields, i'd instead return of fields #tempjointable (the other 2 product fields).

i know exists bit wrong, can't figure out other options there try


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -