[R] using variable in rmysql query

jim holtman jholtman at gmail.com
Sun Nov 7 13:24:47 CET 2010


?paste

 id <- dbGetQuery(con1,paste("SELECT id FROM tenants WHERE name LIKE '%",
       ,str, "%'", sep = ''))

On Sun, Nov 7, 2010 at 4:51 AM, Mohan L <l.mohanphysics at gmail.com> wrote:
> Dear All,
>
> I am using this query it returns id :
>
> id <- dbGetQuery(con1,"SELECT id FROM tenants WHERE name LIKE '%consim%'")
>
> But In my case the string "consim" is there in another variable(it is
> coming from configuration file);
>
>> str <- "consim"
>
> I am trying to replace the string some this like, but it not working:
>
>> id <- dbGetQuery(con1,"SELECT id FROM tenants WHERE name LIKE '%str%'")
>
> I need help to replace the value of str . Any help will really appreciated .
>
> Thanks for your time.
>
> Mohan L
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list