T-SQL: How to Pull from One Query Based on Another Query
Hi There:
Below is my code. This code is returning no results, because its subquery is not returning any results.
I know for certain that the subquery should be pulling data and, therefore, returning results. Yes, the main "idea" is to return LOTs that resemble Components.
When I say "resemble", let me give you an example. 506N is a Component, while 506N418G06A-40 is a LOT. So, I want the subquery to pull 506N418G06A-40 and therefore the full query to display 506N418G06A-40 and other lots that begin with "506N" as results.
Is there something wrong with the syntax of the subquery? Do I need to add syntax for "trimming" strings or something along those lines?
Thanks!
Software Engineer
SELECT DISTINCT [LOT]FROM WIPTESTINNER JOIN IV30200 ON WIPTEST.[INVHDRBATCH] = IV30200.BACHNUMBAND WIPTEST.[INVHDRDOC] = IV30200.DOCNUMBRWHERE [FG] = '506' AND [FGBATCH] = '50418G12D' AND [INVHDRBATCH] = '50418G12D' AND EXISTS (SELECT DISTINCT [LOT] FROM WIPTEST WHERE [LOT] LIKE [Component]+'%')