Search code examples
sqlwhere-clausehaving

SQL having/where statement on alias column


I'm trying to set the result of a column, depending on the value that is given in a query result within the alias table

update autos
    set risico = 0
    where in (select leden.lidnaam, count(deelnemers.evenementnr) as AantalDeelnames
    from leden 
        full join autos on leden.lidnr = autos.lidnr
        full join deelnemers on autos.autonr = deelnemers.autonr
        group by leden.lidnaam
        having AantalDeelnames = 0)

Solution

  • You don't have a field specified in for your IN statement. You should have a field name to compare against the select statement. It will look like WHERE field_name IN (SELECT .....)