首页 新闻 会员 周边

MYSQL 数据插入前判断插入的数据company是否重复!

1
悬赏园豆:10 [已关闭问题] 关闭于 2012-04-09 09:26

字段名分别是company、ID   数据库名db_articlel代码要怎么写呢?

这是我从网上采用的

insert into db_articlel(company,ID,cdate)select 'company' from db_xmrc where not exists(select company from db_articlel where company='$company')

  试了下   不行  高手帮忙下、还有就是PHP中怎样编写每日自动运行 1小时抓取一次数据的代码。抓取的代码自己已经写好  剩下的就是怎样编写每日自动运行 1小时抓取一次数据的代码。

as、的主页 as、 | 初学一级 | 园豆:96
提问于:2012-04-07 11:41
< >
分享
所有回答(1)
0
insert into db_articlel(company,ID,cdate)select 'company' from db_xmrc where not exists(select company from db_articlel where company='$company')

我不知道这句行不行,反正我觉得是有错的样子。

insert into db_articlel (company,ID,cdate) values (@company,@ID,@cdate) where @company not in 
(select 'company' from db_xmrc where company=@company)

至于sql server还是mysql,转换起来都一样的吧。

Ron Ngai | 园豆:296 (菜鸟二级) | 2012-04-08 01:55
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册