SELECT u.*, zz.contid, zz.lng, zz.lat, zz.zip, zz.city, zz.state, (**calc distance**) AS distance FROM contacts zz INNER JOIN users u ON zz.id = u.id WHERE cond1 = 1, cond2=2, etc.. GROUP BY u.id HAVING MIN(distance) < 100 Error: unknown column distance
Any idea why this is? and how to fix it?
I appreciate any advice, many thanks in advance!
MIN()is an aggregate function, its argument must be a column value, not an alias.sqltag. It would be helpful if you also added the specific DBMS you're using.