I have TABLE A with one of the columns containing a single value and TABLE B with one of the columns containing list of possible matching values.
My code seems to take only first items in the list but does not go deeper within a list to find matching number.
Can you please help me to improve the following code:
select Logs.SingleValue,
Instances.list from Logs,Instances
where Logs.Column1=Instances.DeviceNumber and
(',' + RTRIM(Instances.list) + ',') LIKE Logs.SingleValue
The data in the list looks like
106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120
or
3346, 3347, 3348, 3349, 3350, 3351, 3352, 3353, 3354, 3355, 3356, 3357, 3358, 3359, 3360
I use SQL within R programming environment; not sure what version it is. I'm not sure if the DBMS is MS SQL Server or ORACLE. All I know is that I have found a similar case and the command did not work so it needs to be handwritten in pure SQL.