Mysql Query doesn't work as expected (with left joins)

Mysql Query doesn't work as expected (with left joins)

Hello mysql and sql experts

Hello mysql and sql experts

I have a problem with my query.

I have 3 tables (As you can see in the images below)

One table for the event One table for the user account And one table where the event table and user account table is linked to (Teilnehmer table)

When a user Sign up to a event, the EventID and also the UserID will be stored in the Teilnehmer table.

That works fine.

Now the problem is, I've created a query which should only return the events, which are Enabled = 1, the user didn't Sign up to and the Count of FK_eventID is < Event.Anzahl

but that doesn't work.

The Count and Enabled join works, but although the user sign up to a event, the event will still be returned

can anybody see my problem ?

SELECT v.ID, 
       v.NameVeranstaltung, 
       v.Datum, 
       v.Uhrzeit, 
       v.Anzahl, 
       v.Beschreibung, 
       v.Enabled, 
       Count(t.FK_eventID) 
FROM   Veranstaltung AS v 
       LEFT JOIN Teilnehmer AS t 
              ON t.FK_eventID = v.ID 
       LEFT JOIN Users AS u 
              ON t.FK_userID = 17 
WHERE  v.Enabled = 1 
GROUP  BY t.FK_eventID, 
          v.NameVeranstaltung 
HAVING Count(t.FK_eventID) < v.Anzahl 


sql mysql

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Introduction to Structured Query Language SQL pdf

SQL stands for Structured Query Language. SQL is a scripting language expected to store, control, and inquiry information put away in social databases. The main manifestation of SQL showed up in 1974, when a gathering in IBM built up the principal model of a social database. The primary business social database was discharged by Relational Software later turning out to be Oracle.

Best MySQL DigitalOcean Performance – ScaleGrid vs. DigitalOcean Managed Databases

Compare ScaleGrid MySQL vs. DigitalOcean Managed Databases - See which offers the best MySQL throughput, latency, and pricing on DigitalOcean across workloads.

Welcome Back the T-SQL Debugger with SQL Complete – SQL Debugger

Debug SQL stored procedures and develop your SQL database project with dbForge SQL Complete, a new add-in for Visual Studio and SSMS. When you develop large chunks of T-SQL code with the help of the SQL Server Management Studio tool, it is essential to test the “Live” behavior of your code by making sure that each small piece of code works fine and being able to allocate any error message that may cause a failure within that code.

SQL LOWER Function Example | Lower() In MySQL and SQL Server

SQL LOWER Function Example | Lower() In MySQL and SQL Server. The SQL LOWER function converts all the characters in a string into lowercase.