you don't have to do this --
Code:
where (
t.assigned_to like '%,"& session("user_id") &",%'
OR t.assigned_to like '%"& session("user_id") &",%'
OR t.assigned_to like '%,"& session("user_id") &"%'
or t.assigned_to like '"& session("user_id") &"'
)
it's not quite so easy to see it with that honking great parameter in there, so let's simplify it a bit
let's say that t.assigned_to is '3,5,9,37' and let's say that the user_id session variable is 3
your code would say --
Code:
where (
t.assigned_to like '%,3,%'
OR t.assigned_to like '%3,%'
OR t.assigned_to like '%,3%'
or t.assigned_to like '3'
)
but you really don't need this complexity
not only is it complex, it's also wrong!
if t.assigned to were '4,5,9,37' it would incorrectly match '%,3%')
i know what you were thinking, you have to test for user_id 3 inside the list of numbers in t.assigned_to, and also at the beginning of the list, at the end of the list, or equal to the entire list
but what if you concatenate a comma to the front and back of the list?
so instead of using t.assigned_to, which is '3,5,9,37', you used ',3,5,9,37,' instead?
then what you could do is search for ',3,' instead of searching for 3
notice that by searching for ',3,' you won't accidentally return true for 37
now go back to post #4 and see how i did the WHERE clause with just one comparison, not the four that you used
oh, and by the way, i understand that you have put a lot of work into this design, but that's not enough reason to stick with it -- perhaps what you don't understand is how much unnecessary heartache and extra work you are still facing
Bookmarks