Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 1064 when COUNTING DISTINCT

My query statement

SELECT Count(DISTINCT name) 
FROM facebook.users

results to

mysql.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\xef\xbb\xbfSELECT Count(DISTINCT name) \r\nFROM facebook.users' at line 1")

How do I fix this, thanks

like image 821
Hatchet Man Avatar asked Mar 08 '26 15:03

Hatchet Man


1 Answers

You should check how you pass your query. \xef\xbb\xbf is UTF-8 BOM.

The UTF-8 representation of the BOM is the (hexadecimal) byte sequence 0xEF,0xBB,0xBF

SELECT Count(DISTINCT name) FROM facebook.users
-- query is correct
like image 128
Lukasz Szozda Avatar answered Mar 11 '26 05:03

Lukasz Szozda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!