lundi 25 avril 2016

SQLite query OR not returning expected results

I want to run a query where it returns all results that contain either A or B, but it is only returning the first one listed. I can get results from A and results from B when I run them separately, but not with the OR statement.

dbGetQuery(db, "SELECT winery, Name, year, Price FROM Wines
       WHERE price <= 10
       AND name LIKE '%Chardonnay%' OR '%Riesling%'
       ORDER BY price ASC
       LIMIT 10")

Will only return Chardonnay

             Winery                Name Year price
1       Pine & Post          Chardonnay 2004     5
2         Two Vines          Chardonnay 2013     6
3       Pine & Post          Chardonnay 2006     6
4       Pine & Post          Chardonnay 2005     6
5    Columbia Crest Semillon-Chardonnay 2000     6
6       Pine & Post          Chardonnay 2010     7
7       Pine & Post          Chardonnay 2008     7
8  Washington Hills          Chardonnay 2006     7
9         Covey Run Semillon-Chardonnay 2002     7
10        Covey Run Semillon-Chardonnay 2000     7

I have verified that there are at least 3 Rieslings that would be included in this if the query was working properly

Aucun commentaire:

Enregistrer un commentaire