2

I am new to Couchbase noSql database.

I am trying to create a view, i want this view should give result as below SQL query.

SELECT * FROM Employee e WHERE e.name = "DESM%" AND e.salary < 1000 ORDER BY e.id desc

Any suggestion is very appreciated.

Suresh Lakku
  • 95
  • 1
  • 9
  • `ORDER BY` in a view is either a non-standard language feature or an error. If you want to replicate some non-standard behaviour, you'll have to be more specific than "SQL" - what SQL database *product* are you trying to replicate the behaviour of? (In standard SQL, tables and views are *unordered* bags of rows - so an `ORDER BY` within a view doesn't make sense) – Damien_The_Unbeliever Mar 09 '15 at 09:40
  • I got your point. My intention is to query Couchbase as above mentioned sql query. In which way i can achieve it. Any suggestion for it. – Suresh Lakku Mar 09 '15 at 09:47

1 Answers1

1

If you look at existing beer samples in Couchbase (it comes with it), you will find views defined there. In admin console you can run a view. Notice when you run a view you can provide filtering criteria and sort order for the result...that might be an equivalent for your SQL like functionality. Read more on Views and Indexes

yet another option is to use Couchbase v3 that comes with its own N1QL query language that can serve as another alternative. You can try it out online here.

user1697575
  • 2,830
  • 1
  • 24
  • 37