sql server - Combine Multiple ID's as the variable SQL -


writing report , having issue hoping guide me in right direction

i have 2 tables tbl_registermain_holding , lyndseycouncils

in tbl_registermain_holding there 12 columns have la_id_build (1 -12) in them

i want able use variable (5,12,23) = ‘east midlands’ variable bring rows have of numbers in.

here data looks in lyndseycouncils table

la_id   listings 5       east midlands 12      east midlands 23      east midlands 15      east of england 21      east of england 25      east of england 79      london 80      london 201     london 3       london , home counties 11      london , home counties 13      london , home counties 352     north east 365     north east 372     north east 

here query i’m working on

select rm.email,forname,surname,lc.listings dbo.tbl_registermain_holding rm inner join [dbo].[lyndseycouncils] lc on rm.la_id_live = lc.la_id  (rm.la_id_build1 = @council or rm.la_id_build2 = @council or rm.la_id_build3 = @council  or rm.la_id_build4 = @council  or rm.la_id_build5 = @council or rm.la_id_build6 = @council  or rm.la_id_build7 = @council or rm.la_id_build8 = @council or rm.la_id_build9 = @council  or rm.la_id_build10 = @council  or rm.la_id_build11 = @council or rm.la_id_build12 = @council) 

this work if using 1 la_id because i’m using multiple la_id should in () have no idea how write that, maybe i’m going in wrong way. appreciated. thanks


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -