我将使用SQLAlchemy core从一个mysql
表中选择行,使用IFNULL
函数。
假设有如下表:
id int1 string1 other
1 7 NULL other stuff
2 NULL bar more stuff
SQL语句应该是这样的:
SELECT IFNULL(int1, 0) AS int1, IFNULL(string1, '') AS string1 FROM table
这是否可以使用核心实现?最好的情况是类似以下示例:
s = select(ifnull(table.c.int1, 0), ifnull(table.c.string1, ''))