如何编写查询以便我可以根据另一个行值插入一行

How to write a query so that I can insert a row based on another row value

谁能帮我构建一个 SQL 查询,这样我就可以根据条件插入新行。假设有任何行 属性 为“Name” 那么我需要插入一个新行 属性, VALUE --> ("老板", "在场") else 属性, VALUE -->("老板", "不在").请注意,我不想使用“双”table,因为我没有使用 oracle DB。先感谢您。 下面是我的 DB table 结构。

编辑 1:属性 是主键。

您可以使用 case 表达式和 exists 条件:

insert into mytable (property, value)
select 'Boss',
    case when exists(select 1 from mytable where property = 'name') 
        then 'isPresent' 
        else 'isAbsent' 
    end
from dual