Sql query print one record overwrite if both action are present 覆盖和插入
Sql query print one record overwrite if both action are present overwrite and insert
enter image description here当动作是插入和覆盖时,输出给出覆盖,
当只有一行 (insert/overwrite) 存在时,它应该只给出一行
http://sqlfiddle.com/#!9/89c941/3
create table data(id int, action varchar(50));
insert into data(id, action) values(1,'Insert'),(2,'Overwrite'),(3,'Insert Overwrite'),(4,'Overwrite Insert')
select id,
action,
case when action like '%Overwrite%'
then 'Overwrite'
else action
end as Output
from data
创建 TABLE userData(_id INT, name VARCHAR(50));
插入数据(id,名称)值(1,'abc'),(2,'xyz')
SELECT _id, case WHEN name LIKE '%xyz%' THEN 'xyz' ELSE name end AS Output
来自用户数据;
enter image description here当动作是插入和覆盖时,输出给出覆盖, 当只有一行 (insert/overwrite) 存在时,它应该只给出一行
http://sqlfiddle.com/#!9/89c941/3
create table data(id int, action varchar(50));
insert into data(id, action) values(1,'Insert'),(2,'Overwrite'),(3,'Insert Overwrite'),(4,'Overwrite Insert')
select id,
action,
case when action like '%Overwrite%'
then 'Overwrite'
else action
end as Output
from data
创建 TABLE userData(_id INT, name VARCHAR(50));
插入数据(id,名称)值(1,'abc'),(2,'xyz')
SELECT _id, case WHEN name LIKE '%xyz%' THEN 'xyz' ELSE name end AS Output
来自用户数据;