MYSQL Union initializes 0 and False as a bigint

Viewed 55

I'm trying to union to tables together into a view but when the second table fills with (false or 0), it will convert the tinyint(1) into a bigint.

CREATE OR REPLACE VIEW people AS
SELECT 
    `id`, /*int*/
    `active` /*TINYINT(1)*/
FROM
    `table1` 
UNION ALL 
SELECT 
    `id`, /*int*/
    0 AS `active` /* fill second column */
FROM
    `table2`

When I look at the fieldtype description it says

id     | int    | binary | 11 | 2  | 0 |
active | bigint | binary | 19 | 19 | 0 |

How can I get get the active (supposed to be bool/tinyint(1)) to stay the same data type after unioning?

1 Answers

I just sent it in as null and when I checked it I returned false if it == null. basically giving me a 0/false constant return.

Related