mysql-error-1111

counting rows that date hasn't yet passed

I am trying to count the number of rows whose date has not yet passed so i can get only the current records I get an error sayng MySQL error #111 Invalid use of group function SELECT COUNT(festivalid) FROM festivals WHERE min(datefrom) > now() ...

mysql use group by column in where condition

How can I make this query work : SELECT column1.....,SUM(Hits) AS Hits FROM table WHERE SUM(Hits) > 100 GROUP BY column1..... The problem is the where clause, mysql display error : Error Code : 1111 Invalid use of group function I try to change the query to : SELECT column1.....,SUM(Hits) AS Hits FROM table WHERE...

Why would this SQL error with "Invalid use of group function"?

This is a simple query ran when the user presses logout from my website UPDATE `user_logins` SET `active` = 0 WHERE `user_id` = 3 AND `datetime` = MAX(`datetime`) LIMIT 1 The user_id value is binded in there with PDO. I get the following exception thrown Invalid use of group function Googling around seems to say that ...

mysql query to update field to max(field) + 1

What I want to do is: UPDATE table SET field = MAX(field) + 1 WHERE id IN (1, 3, 5, 6, 8); The semantics of this statement, in my mind, would be first the database would go off and determine for me what the largest value of field is in all of table. It would then add 1 to that value, and assign the resulting value to the field column ...

Mysql query - invalid use of group function

mysql_query(" SELECT b.id as b_id FROM banner b INNER JOIN bannerhits bl ON b.id = bl.bannerid AND bl.userid = '".$this->userid."' INNER JOIN ...

MySQL: Delete singular entires

If I have this table: +------+-------+---------------+--------+-----------------+------------+-----------+----------------+------+------+--------+------------+------------+ | type | class | username | userid | userip | usermobile | useremail | daysleft| pin1 | pin2 | pin3 | active | schoolname | schoolsite | +------+------...

Mysql error 1111 in one version of query and error 1054 in another

I have two tables: books: [isbn, book_title, publisher, ...] inventory: [isbn, date, num_changed] I want to return book titles for those which are on stock. I tried a join (query 1) and got 1054 error, then I substituted the reference with the literal value and now I get 1111 error. query 1: SELECT `books`.`isbn`, `books`.`book_t...

Help with a select count query

I want to show all cities that have have a count > 5. I have tried to limit my results anything over a count of 5 but it isn't working. SELECT user.city, Count(user.city) AS cnt FROM user Inner Join zip ON zip.zip = user.zip WHERE cnt > 5 GROUP BY user.city WHERE cnt > 5 **<--------------- It fails here** cnt has already been defined ...

MySQL fetch a field where the field exists > x times in table

I'm trying to do the following in MySQL: SELECT DISTINCT field FROM table WHERE COUNT(field) > 10 Which fails with: 1111 - Invalid use of group function (from what I understand, you can't use group functions such as COUNT in the where clause?) What is the proper way of selecting (distinct) all fields which are present in at least N r...

Strange Mysql error 1111, supposedly worked before...

I am trying to troubleshoot a particular 'report' that gets generated on a PHP application running on a VOIP platform (billing related). The person that asked me to do this stated "it worked before" ;) MySQL Error thrown: 1111: Invalid use of group function Crazy thing is, it 'worked before' but stopped after awhile, they cannot place ...