要仅检查表中是否已有Lion:
select count(*) from animals where name = 'Lion'
您可以使用
where子句在一个查询中进行检查和插入:
insert into animals (name) select 'Lion'where not exists ( select * from animals where name = 'Lion' )
为了回应您的评论,请选择一个动物子列表:
select name from animals where name in ('Lion', 'Tiger', 'Jaguar')对于每个已经存在的动物,这将最多返回3行。



