Unknown Column?

Posted by Kenny on Stack Overflow See other posts from Stack Overflow or by Kenny
Published on 2011-02-10T22:54:50Z Indexed on 2011/02/10 23:26 UTC
Read the original article Hit count: 203

Filed under:
|
|
|

ok im trying to get mutual friends between these Two users, user1 and user92

This is the sql that is successful in displaying them

SELECT IF(user_a = 1 OR user_a = 92, user_b, user_a) friend
            FROM friendship
            WHERE (user_a = 1 OR user_a = 92) OR (user_b = 1 OR user_b = 92)
            GROUP BY 1
            HAVING COUNT(*) > 1

THis is how it looks

friend
61
72
73
74
75
76
77
78
79
80
81

So now i want to select all users after the number 72, and i try to do it with this sql but its not working? It gives me the error, "unknown coulum name friend in where clause"

SELECT IF(user_a = 1 OR user_a = 92, user_b, user_a) friend
            FROM friendship
            WHERE friend > 72 and (user_a = 1 OR user_a = 92) OR (user_b = 1 OR user_b = 92)
            GROUP BY 1
            HAVING COUNT(*) > 1

what am i doing wrong? or what is the correct way?? thx

© Stack Overflow or respective owner

Related posts about php

Related posts about sql