I would like to know if it is possible to find the value in the select statement and use it in the where clause, for example:
SELECT col1, MAX(col2) - COUNT(DISTINCT col3) as variable FROM table WHERE col1 > variable
the βtableβ is quite large, and I want to narrow down the records that the query should look at as quickly as possible.
I know that this is not a bit of code, it is impossible, as it is written (# 1054 - Unknown column "variable" in the "where" section), but still you need to find out the value of "variable" and then use this in the WHERE clause?
sql mysql aggregate-functions
Troy Knapp Aug 25 '10 at 15:57 2010-08-25 15:57
source share