I want to get only those rows where product is fan. The table and SQL code are:
Table - _customer_data.customer_purchase_
| row | product |
|---|---|
| 1 | fan |
| 2 | fan |
| 3 | bed |
Code
SELECT
*
FROM
'customer_data.customer_purchase' LIMIT 1000
WHERE
product='fan';
Syntax error: Expected end of input but got keyword WHERE at [4:1]
CodePudding user response:
LIMIT is applied to a whole query's results, not to just one table.
As SQL sets are unordered (a multitude of factors can cause the set to be read in different orders), you should also specify an ORDER BY, whih goes after the WHERE.
This means that you need something like...
SELECT
*
FROM
yourTable
WHERE
yourTable.product='fan'
ORDER BY
yourTable.something
LIMIT
1000
