i-CONICA
i-CONICA

Reputation: 2379

Anything wrong with this query? It's returning one result twice, I can't figure out why

I've got this query, which searches for auctioneers by name, getting data from more than one table.

It's returning on result twice, even though it's using "distinct", but I can't figure out what's going on...

It'd be difficult to offer a sample of data, but I'm hoping some SQL genius can offer suggestions to possible causes...

SELECT DISTINCT a.id,a.name, al.city
FROM auctioneers a
LEFT JOIN auctioneersloc al ON al.auctioneerId = a.id
LEFT JOIN auctioneerscont ac ON ac.auctioneerId = a.id
WHERE a.name LIKE "%Jones%"
GROUP BY city

Thanks.

Upvotes: 0

Views: 97

Answers (1)

Li0liQ
Li0liQ

Reputation: 11264

This could happen if you have duplicating al.auctioneerId or ac.auctioneerId in appropriate tables - you'll be getting one the same record from auctioneers returned per each id match.

Upvotes: 1

Related Questions