I'm adding information to a view via UNION. I currently have booleans in the table represented by TINYINT. I need to maintain these columns as TINYINT. The following information in the UNION alters the datatype to BIGINT:
<PREVIOUS SELECT (Type of isRequired = TINYINT)>
SELECT isRequired
FROM tableA
UNION
<NEW SELECT (After this, isRequired = BIGINT)>
SELECT
1 AS isRequired
FROM tableB
Apparently, MYSQL CAST() will not convert to TINYINT. How can I preserve the TINYINT in the original view?
I don't know why you "need to maintain these columns as
TINYINT". However - One workaround would be to define a custom function which returns aTINYINTvalue.Then your query would be
You can test it storing the result into a (temporary) table.
Original query:
Result:
Using custom function:
Result:
View on DB Fiddle