Loans | Mortgages | Personal Loans | Debt Help | Repair Bad Credit
1064 MySQL Syntax Error [Archive] - PCMech Forums

PDA

View Full Version : 1064 MySQL Syntax Error


james8547
09-16-2003, 09:15 PM
I am new to MySQL and I got this error in 1 of the sites that I am working on:

1064 - You have an error in your SQL syntax near 'distinct p.products_id) as total from products p left join manufacturers m usin' at line 1

select count(distinct p.products_id) as total from products p left join manufacturers m using(manufacturers_id), products_description pd left join specials s on p.products_id = s.products_id, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%remote%' or p.products_model like '%remote%' or m.manufacturers_name like '%remote%') )

[TEP STOP]

Any ideas on what caused this and how to fix it? This is the 1st time I encountered this kind of error. Thanks

doctorgonzo
09-17-2003, 09:34 AM
I'm not sure how well MySQL conforms to SQL standards, but the first thing I would do is remove the DISTINCT keyword from inside the parentheses. It should be after the SELECT keyword.

mairving
09-17-2003, 10:04 AM
It should work nevertheless. The question is why do you need to use distinct anyway. If it is a product_id coming form the product table, it should be a primary key and thus unique.

Probably replace the using with an on.