Question
Query to find a single value from fields containing a list
Ok, my db fields contain a list of sections, " 1,2,3,4,"
I only want to select the fields which contain the number '2'
I know i'd use the query
SELECT *
FROM db
WHERE ID IN ('#mylist#')
If i were doing things the other way... but I can't find out how to the opposite (if that makes sense?)
Apparently because my table is not indexed as full text (?!!) i can't use CONTAINS..
any ideas?
This is my query so far:
SELECT Job_ads.*, CONVERT(nchar ,Job_ads.ID) + '|' + Job_ads.image + '|' + Job_ads.Alt
AS jobadstr
FROM Job_ads
WHERE image <> ''
AND dispfrom < #now()#
AND dispto > #now()#
but I need to add
AND type (has value '2' in it)
somehow
I only want to select the fields which contain the number '2'
I know i'd use the query
SELECT *
FROM db
WHERE ID IN ('#mylist#')
If i were doing things the other way... but I can't find out how to the opposite (if that makes sense?)
Apparently because my table is not indexed as full text (?!!) i can't use CONTAINS..
any ideas?
This is my query so far:
SELECT Job_ads.*, CONVERT(nchar ,Job_ads.ID) + '|' + Job_ads.image + '|' + Job_ads.Alt
AS jobadstr
FROM Job_ads
WHERE image <> ''
AND dispfrom < #now()#
AND dispto > #now()#
but I need to add
AND type (has value '2' in it)
somehow