O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

When the SQL query is long

When the SQL query is long, it becomes unwieldy to specify the whole query as one long string spanning several lines. Use the paste() function to break the query over multiple lines and make it more readable:

> dbSendQuery(con, statement=paste( 
   "select ordernumber, orderdate, customername", 
   "from orders o, customers c", 
   "where o.customer = c.customer", 
   "and c.state = 'NJ'", 
   "ORDER BY ordernumber")) 
Note the use of the single quotes to specify a string literal.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required