Skip to content
Advertisement

create user defined WHERE SQL phrase in r

I am using RODBC to connect to a database. I would love for a user to be able to define wildcard strings to lookup in the SQL as part of a function. I cannot use CONTAINS as the database is not full-text indexed.

The SQL I want to create is

The user should be able to define as many wildcards as they like, all from the ItemNM field and all separated by OR.

If I vectorise the userdefined (ie userdefined<-c("US","MRI")) then I end up with separate SQL strings which is no good. How can I get the output as above but for any length of user defined string where they are just defining the wildcard?

Advertisement

Answer

You could use :

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement