站外推广6种方法,数据分析培训班,网站建设古典风格,怎么设计一个自己的网站今天有个需求, 已减高度 高度 x 单双开(单开1 双开2) x 2,要直接写在sql语句中。
表字段 包含 高度 和 单双开字段 值是字符串 (双开 左单开 右单开)
-- 已减高度 2 * 单双开 * 高度
sum(
-- 求和 表达式 已减高度 2 * 单双开 * 高度
t_cloth.hegiht * 2 *
(case WHEN l…今天有个需求, 已减高度 高度 x 单双开(单开1 双开2) x 2,要直接写在sql语句中。
表字段 包含 高度 和 单双开字段 值是字符串 (双开 左单开 右单开)
-- 已减高度 2 * 单双开 * 高度
sum(
-- 求和 表达式 已减高度 2 * 单双开 * 高度
t_cloth.hegiht * 2 *
(case WHEN locate(双开,t_cloth.open_with) 0 then 2
when locate(双开,t_cloth.open_with) 0 then 1
end)
) as hegiht_sum,locate(字符,字段名) 使用locate(字符,字段名)函数如果包含返回0的数否则返回0 它的别名是 position in select * from 表名 where locate(字符,字段) select * from 表名 where position(字符 in 字段); 例子判断site表中的url是否包含’http://子串,如果不包含则拼接在url字符串开头 update site set url concat(‘http://’,url) where locate(‘http://’,url)0 参考资料 大神博客