How can I cast an int to a bit in MySQL 5.1?

前端 未结 3 1255
你的背包
你的背包 2020-12-02 00:03

I am transitioning from SQL Server to MySQL 5.1 and seem to be tripped up trying to create a table using a select statement so that the column is a bit.

Ideally the

3条回答
  •  孤城傲影
    2020-12-02 00:25

    Try using case:

    CREATE TABLE myNewTable AS
    SELECT (case myIntThatIsZeroOrOne when 1 then true else false end) AS myBit
    FROM myOldtable
    

提交回复
热议问题