1

On Localhost this query works correctly, running normal MySQL:

SELECT COUNT(*) as rows, customers. * 
FROM customers 
WHERE user_id = 6 
      AND age = 10 
ORDER BY timestamp DESC LIMIT 0

However on the latest mariadb it throws up this:

SELECT COUNT(*) as rows, customers. * 
FROM customers 
WHERE user_id = 6 
      AND age = 10 
ORDER BY timestamp DESC LIMIT 0

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'rows, customers. * FROM customers WHERE user_id = 6 AND age' at line 1 Time: 0.011s

Anyone know why this would be?

1
  • Is this a real question? I have no idea what you mean by "it works correctly" but the query is useless. Commented Dec 5, 2018 at 7:59

1 Answer 1

5

rows is a reserved keyword in MariaDB.

https://mariadb.com/kb/en/library/reserved-words/

Unless you single- or double- or backquote it:

select id as 'rows' from tbl;
select id as "rows" from tbl;
select id as `rows` from tbl;

db<>fiddle here

As commented by dbdemon, rows is now a reserved word in MySQL too, specifically starting from version 8.0.2. See another db<>fiddle demo here.

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.