判断2张表中是否有数据,如果没有插入数据

业务需求
      明星表和疑似明星表中,如果都没有明星信息,就把数据插入到疑似明星表中, 为了减少数据库的交互,判断2张表中是否存在,如果存在就不插入数据,
实现逻辑
     通过明星的姓名,查询表的条数,然后相加
     SELECT (SELECT  count(*) FROM tab_star_info star where upper(star.name)=upper(?)) +  (SELECT count(*) FROM tab_star_info_doubt starDoubt where upper(starDoubt.name)=upper(?)) as total

猜你喜欢

转载自dichaoying.iteye.com/blog/2294254