ISNULL函数+case函数+LEFT JOIN函数

ISNULL函数

说明:

在SQLite中没有isnull函数

在sqlite中想要使用isnull函数,可以使用ifnull函数,跟isnull用法一样。

例子:

select ifnull(catid,0) from category

CASE函数

格式:

case 字段

when 值1 then 结果

when 值2 then 结果

else  结果

end

例子:

case ifnull(d.dept_name,'') when '' then c.dept_name
else d.dept_name||'/'||c.dept_name end

LEFT JOIN函数

说明:

left join on后面也是可以接 and作为条件进行拼接的

例子:

left join t_ec_dept d on d.id = c.par_dept_id and d.ec_id = c.ec_id

猜你喜欢

转载自my.oschina.net/u/2253892/blog/335479
今日推荐