日期:2014-05-17  浏览次数:20477 次

求SQL语句,如果满足条件则插入记录
我要实现当表中记录不满100条时插入记录,
我写了下面的语句但是没法实现我的想法,请高人指点,应该怎样写
strSQL.Format("insert into table1 ([id],[date],[money],[manager]) values('%s','%s',%.2f,'%s') where (select count(*) from table1) <  100",No,Date,money,manager);

------解决方案--------------------
搞什么飞机,你在外面统计行数,然后if 行数<100,就执行插入,否则跳过,不就得啦
------解决方案--------------------
if (select count(*) from table1)<100

insert into table1()...
------解决方案--------------------

strSQL.Format("insert table1(id,date,money,manager) select '%s','%s',%.2f,'%s' from table1 having count(*)<100",No,Date,money,manager); 
------解决方案--------------------
搞毛?有if不用非得一条语句实现
------解决方案--------------------
strSQL.Format("insert table1(id,date,money,manager) select '%s','%s',%.2f,'%s' from table1 having count(*)<100",No,Date,money,manager);