ok Posted December 6, 2008 Share Posted December 6, 2008 yo! $query = "SELECT invited_by, COUNT(*) AS total FROM users WHERE total=$total AND invited_by!='' AND date_check='0000-00-00 00:00:00' GROUP BY invited_by ORDER BY total DESC LIMIT 1"; i used two AND there. is that correct? what is the not? thank you. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted December 6, 2008 Share Posted December 6, 2008 Perhaps it's just me, but i've absolutely no idea what your question is. What is the problem? Quote Link to comment Share on other sites More sharing options...
ok Posted December 6, 2008 Author Share Posted December 6, 2008 the error is this, Problem with the query: SELECT invited_by, COUNT(*) AS total FROM users WHERE total=3 AND invited_by!='' AND date_check='0000-00-00 00:00:00' GROUP BY invited_by ORDER BY total DESC LIMIT 1 on line 79 Unknown column 'total' in 'where clause' Quote Link to comment Share on other sites More sharing options...
Mchl Posted December 6, 2008 Share Posted December 6, 2008 Can't use aliases in WHERE clause Use "HAVING total = 3" Quote Link to comment Share on other sites More sharing options...
gevans Posted December 6, 2008 Share Posted December 6, 2008 You can't set an alias for use in the sql query. I think you want to use LIMIT or run the query and check the number of results afterwards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.