I currently have a query that returns results based on a dynamic set of conditions
DataTable Items:
ID Title
1 Some title
2 Some other title
..etc..
.
DataTable Tags:
ID Tag
1 'a1c'
1 'a1d'
2 'a2c'
..etc..
My current search Query:
select * from dbo.Items i
LEFT JOIN dbo.tags t
on i.ID = t.ID
INNER JOIN @input in
on (in.[input] = t.Tag or in.[input] is null)
An input would be something like:
DECLARE @input as inputTable_type
INSERT INTO @input VALUES ('a1c')
What I would like to do is use a value like 'a1%' as an input, but when I try that, I get no results (although I do know that a query such as the following does work):
select * from dbo.Items i
INNER JOIN dbo.tags t
on i.ID = t.ID
and t.Tag like ('a1%')
Unfortunately, I want to keep it a static query, and as far as I know, I need the LEFT JOIN - INNER JOIN combination that I have in order to be able to pass VALUES (NULL)
into the stored procedure.
Thanks for any thoughts and help, and let me know if I can clarify anything!