2

I wanna join two buckets by below query. But it throws me an error like below. What am I missing?

Error:

syntax error - at ebook_id

Query:

 SELECT ebook_id, COUNT(*) as count 
        FROM `log` USE KEYS `log.`ebook_id 
        JOIN `product` USE KEYS product.book_id
        WHERE meta(`log`).id LIKE 'ebook_page_request%' AND `log`.date = CLOCK_LOCAL('1111-11-11') GROUP BY log.ebook_id
1
  • 1
    This looks like a typo? Check the placement of your backticks around log in the FROM clause Commented Jun 8, 2018 at 16:12

2 Answers 2

2
 FROM `log` USE KEYS `log.`ebook_id 

The back tick location is incorrect it needs to end before dot Like below

FROM `log` USE KEYS `log`.ebook_id 

USE KEYS on LEFT side of JOIN needs to be CONSTANT and right of side of JOIN can't use USE KEYS and it must be ON KEYS with expression referring from left side bucket

ANSI JOINS are supported only in CB 5.50

Pre CB 5.50 supports LOOKUP and Index Joins

Sign up to request clarification or add additional context in comments.

Comments

0

Actually, it's usually not necessary to use the back-ticks at all. Just use the plain name of the bucket or field.

The back-ticks are escapes, used to allow you to refer to buckets and fields that contain characters that are not allowed by default in identifiers in N1QL. The most notable of these special characters is - (the minus sign), which is unfortunately used in Couchbase's example data sets, like beer-sample.

By default, do not use `` back ticks.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.