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. Link to comment https://forums.phpfreaks.com/topic/135795-very-simple-spot-the-not/ 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? Link to comment https://forums.phpfreaks.com/topic/135795-very-simple-spot-the-not/#findComment-707618 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' Link to comment https://forums.phpfreaks.com/topic/135795-very-simple-spot-the-not/#findComment-707622 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" Link to comment https://forums.phpfreaks.com/topic/135795-very-simple-spot-the-not/#findComment-707624 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 Link to comment https://forums.phpfreaks.com/topic/135795-very-simple-spot-the-not/#findComment-707626 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.