|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi
I am having problems with the HAVING clause. I know it can use aliases but the alias I am using has a space in it, eg 'Device ID' My querry looks like (simplified, devID is a calculation) SELECT devID AS 'Device ID' FROM tblDevice HAVING 'Device ID' = '123' and it does not work but if I use SELECT devID AS 'Device_ID' FROM tblDevice HAVING Device_ID = '123' everything works. How can I use an alias that contains a space in the HAVING clause? Thanks Steve |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
sanderson82@gmail.com wrote:
> How can I use an alias that contains a space in the HAVING clause? MySQL uses back-ticks `` as the default identifier delimiter. Try this: SELECT devID AS `Device ID` FROM tblDevice HAVING `Device ID` = '123' Regards, Bill K. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
>I am having problems with the HAVING clause. I know it can use aliases
>but the alias I am using has a space in it, eg 'Device ID' *WHY* does the alias have a space in it? Use backquotes, not single quotes, to quote field names. Use single quotes, not backquotes, to quote strings. >My querry looks like (simplified, devID is a calculation) > >SELECT devID AS 'Device ID' FROM tblDevice HAVING 'Device ID' = '123' SELECT devID AS `Device ID` FROM tblDevice HAVING `Device ID` = '123' Gordon L. Burditt |
|
![]() |
| Outils de la discussion | |
|
|