I am not an expert when it comes to phpMyAdmin. Here's the issue i'm facing:
update v_attente_service vas
join tick4 ti on ti.ticket_id = vas.NOMBATTE
set vas.NOMBATTE = COUNT(ti.ticket_id)
where vas.CODESERV=4
I want to display a queue and update the number of people waiting each time a new person prints a ticket. The query above will update the number of people waiting with the count of the tickets.
When i execute the query, i get the following error: "#1111 - Invalid use of group function"
I did find similar questions, and i did try the suggested solutions, however, none of them seem to work. So any help would be very appreciated!
[EDIT]: Here's the solution that worked for me:
UPDATE v_attente_service AS vas
JOIN (SELECT COUNT(ticket_id) AS cnt FROM tick4) AS ti
SET vas.NOMBATTE = ti.cnt
WHERE vas.CODESERV=4;
I hope this helps others facing a similar issue!
You can check with this query:
UPDATE v_attente_service AS vas
JOIN (SELECT ticket_id,COUNT(ticket_id) AS cnt FROM tick4 GROUP BY ticket_id ) AS ti
ON ti.ticket_id = vas.NOMBATTE
SET vas.NOMBATTE = ti.cnt
WHERE vas.CODESERV=4;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.