I'm using MariaDB v5.x and want to return a long database's name with the query. I can successfully do this with a simple query, but with a more involved query the database name comes back truncated [34 characters]. Why does this happen and is there a way to retrieve the full, un-truncated name?
This example query works:
SELECT DATABASE() as 'database', hour as 'hour'
FROM time
WHERE hour = 1;
However, this type of query returns the truncated database name:
SELECT DATABASE() as 'database',
t.hour as 'hour',
d.day as 'day'
FROM time t,
day d
WHERE t.day_pk = day.pk AND
t.hour = 1 AND
d.day = 22
UNION ALL
SELECT DATABASE() as 'database',
t.hour as 'hour',
d.day as 'day'
FROM time t,
day d
WHERE t.day_pk = day.pk AND
t.hour = 1 AND
d.day = 24;
Thanks for any /all help.
D.
CAST(...)
on at least the first Select.d.day in (22,24)
. FWIW, I would avoid identifiers like time and day since they are reserved words (and no I would not use quotes to get around that problem). You may also want to have a look at ANSI joins instead of ",". In the long run I find it easier to maintain my code with these.time
andday
. As for using ASNI joins ... this format is, for me, the easiest to read and use when trying to tie a dozen tables together. Finally, since I'm not an SQL guru, any example of thed.day in (22,24)
would be most helpful.