Just Starting N1QL. Query received a Syntax Error?

Hi there. I’m just starting out on CouchBase and N1QL and I was following the guidelines outlined in https://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-intro/cbq.html#concept_s5k_qtx_1t

I ran the query select * from beer-sample limit 1; and I received a error 300 “syntax error - at from”

I assume the syntax is fine but that there maybe something else going on?

The previous statement ( create primary index on beer-sample; ) worked as expected.

Here is a copy and paste
select * from beer-sample limit 1;
{
“requestID”: “27623106-39c8-40e8-851b-128f7a04f0e3”,
“errors”: [
{
“code”: 3000,
“msg”: “syntax error - at from”
}
],
“status”: “fatal”,
“metrics”: {
“elapsedTime”: “498.9µs”,
“executionTime”: “498.9µs”,
“resultCount”: 0,
“resultSize”: 0,
“errorCount”: 1
}
}

Could be an encoding or quoting issue. Are you using cbq shell, and did you use back ticks to escape beer-sample?

As Gerald says, any time you have a bucket (or field) name with a “-” or " " in the name, you need to quote it with back-ticks. E.g.,

select * from `beer-sample` limit 1;

(p.s., in these forums, the back ticks get hidden by the editor unless you quote them!)