[R] Forming SQL Query at run-time
Rahul Thathoo
rahul.thathoo at gmail.com
Fri Nov 17 05:21:29 CET 2006
Hi.
I am trying to get data from mysql database using a couple of queries.
I do one query to find out the indexes. Then i need to use these
indexes in another query, but i keep getting errors.
Here is something:
numb <- dbSendQuery(con2, "select distinct(comparison) from table1")
count <- fetch(numb, -1)
my.matrix <- as.matrix(count)
rs <- dbSendQuery(con2, "select A.comparison,A.id, A.q_value,
B.q_value from table1 as A, table1 as B where A.comparison =
'my.matrix[11481]' AND B.comparison = 250 AND A.id = B.id")
RS-DBI driver: (could not run statement: You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near '[11481] AND B.comparison = 250 AND
A.id = B.id' at line 1)
And then later I need to do this in a loop, so the array index in
my.matrix will also be another variable. How do I do it? Anyhelp would
be appreciated.
Thanks
Rahul
--
And then there was a man who drowned in a stream 4.5 feet in depth.
MORAL OF THE STORY: Always measure the standard deviation first!
-----
Rahul Thathoo
http://cs.stanford.edu/~thathoo
http://blogs.siliconindia.com/rahul
Cell: 001 650 391 5584
More information about the R-help
mailing list