Error: unexpected symbol in " ON a.guest_id"

Viewed 114
sqldf('Select a.guest_id,case when b.guest_id is not null then 'old' else 'new' end as tagging from JDUniqueGuestid as a
left join UniqueGuestidallsource b
ON a.guest_id = b.guest_id', drv="SQLite")

After running the above code getting below mentioned error, kindly help me and resolve the issue

Error: unexpected symbol in " ON a.guest_id"

1 Answers

You have single quotes around the whole query, but also single quotes within the query; it's not being parsed the way you intend it to.

Depending on the larger context, something like this might work:

"Select a.guest_id, case ... 'old' else 'new' ... ON a.guest_id = b.guest_id"

or you might need to escape the single quotes with something like this:

'Select a.guest_id, case ... \'old\' else \'new\' ... ON a.guest_id = b.guest_id'

It depends on the context in which that query string appears, and how it parses quoted strings.

Related