Details
-
Bug
-
Resolution: Fixed
-
Major
-
None
-
None
-
*Location*: http://docs.couchbase.com/admin/admin/Views/views-translateSQL.html
*User-Agent*: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36
*Referrer*: http://docs.couchbase.com/admin/admin/Views/views-geospatial.html
*Screen Resolution*: 1680 x 1050
*Location*: http://docs.couchbase.com/admin/admin/Views/views-translateSQL.html *User-Agent*: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36 *Referrer*: http://docs.couchbase.com/admin/admin/Views/views-geospatial.html *Screen Resolution*: 1680 x 1050
Description
In the last example of the "Translating SQL WHERE to map/reduce", I think that equivalent SQL for the following query should be different:
?startkey=["carrot","rice",0]&key=["carrot","rice",20]
Original query:
SELECT recipeid FROM recipe JOIN ingredients on ingredients.recipeid = recipe.recipeid
WHERE (ingredient = 'carrot' OR ingredient = 'rice') AND totaltime = 20
This query is inaccurate because it returns the recipes which have at least one of the ingredient and its total time is exactly 20 minutes.
My suggested query:
SELECT recipeid FROM recipe
JOIN ingredients i1 ON ingredients.recipeid = recipe.recipeid
JOIN ingredients i2 ON ingredients.recipeid = recipe.recipeid
WHERE (i1.ingredient IN ('carrot',rice')) AND
(i2.ingredient IN ('carrot',rice')) AND
(totaltime < 20 AND totaltime > 0)
Cheers
Reporter: Eyal
E-mail: mush.eyal@gmail.com