mysql - SQL - Unable to condition an alias due to Unknown column in where clause -
i got following query, when execute error - #1054 - unknown column 'adress' in 'where clause'
wondering why? when remove clause appears column, no idea why throws error.
select zlec_status.nazwa status, piorytet.nazwa priorytet, concat(koord.imie, ' ', koord.nazwisko) `koordynator`, concat(zlec_adresy.miasto, ' - ', zlec_adresy.ulica, ' ', zlec_adresy.oddzial) `adress`, zlec_z_dnia,zlec_id, zlec_nr, zlec_do, zlec_ogran, awizacje, awizacja_na_dzien, termin_zamkniecia, tresc, uwagi zlec inner join koord on zlec.koord = koord.id inner join zlec_adresy on zlec.zlec_addres = zlec_adresy.id inner join piorytet on zlec.priorytet = piorytet.id inner join zlec_status on zlec.status_zlecenia = zlec_status.id `adress` '%some%'
you cannot use column alias defined in select
in where
clause select
. have 2 choices. mysql extends use of having
, can use that:
having `adress` '%some%'
or, can use full expression:
concat(zlec_adresy.miasto, ' - ', zlec_adresy.ulica, ' ', zlec_adresy.oddzial) '%some%'
or, can use subquery, wouldn't recommend that.
Comments
Post a Comment