SELECT count(*) FROM (
... your query ...
) AS x
If your query starts with 'SELECT *' and joins to one or more other tables, then any column name which appears in more than one table will be flagged as a duplicate. You can get around this by specifying 'SELECT <table>.*' so that it ignores columns on any JOINed tables.