mysql 字符串处理函数有没有比较给值的
mysql 字符串处理函数有没有比较给值的需求如下:
源头表 a(字段operation,char型)
目的表 b (字段status int型)
映射 ===》operation is mapped to status, V-->0, others-->1
(中文意思是 a表的字段operation的值如果是‘V’,那么他在b的status里的值为0;如果a表的字段operation的值不是‘V’,那么他在b的status里的值为1)
请问如何写这个sql (必须用到一个字符串函数,在oracle和sqlserver是相当简单的 ,但是mysql着了好长时间还是无果。)
火急!!
(例如:selectif(a.operation=='V')b.status=0else ...b.status=1 ;;
用case when也可以的
) select case when (operation=='V') then 0 else 1 from a
页:
[1]