Mysql
 sql >> Database >  >> RDS >> Mysql

Colonna MySQL Tinybit(1) attraverso una vista

https://www.db-fiddle.com/f/igDh3aJEXRLZEkL7eNrcnc/0

CREATE FUNCTION get_tinyint(MY_BOOLEAN tinyint) RETURNS TINYINT(1) 
RETURN COALESCE(MY_BOOLEAN, 0);

CREATE OR REPLACE VIEW TEST_VIEW AS
SELECT 
    T1.ID AS ID,
    get_tinyint(T2.MY_BOOLEAN) AS MY_BOOLEAN
FROM
    TEST1 T1 LEFT JOIN TEST2 T2 ON T1.ID=T2.TEST1_ID;