sql语句"insert into " . TABLE_PRODUCT_TO_EFFECT. "
                    (product_id, effect_name)
                    values ('" . (int)$products_id . "', '" . $value . "') where not exists(select *from " . TABLE_PRODUCT_TO_EFFECT. " where product_id='" . (int)$products_id . "' and  effect_name='" . $value . "')"
报错,
报错信息如下:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where not exists(select *from product_to_effect where product_id='188' and effe' at line 3
in:
[insert into product_to_effect (product_id, effect_name) values ('188', '关节炎') where not exists(select *from product_to_effect where product_id='188' and effect_name='关节炎')]

解决方案 »

  1.   

    你把这句放到phpmyadmin里去执行一下看看
      

  2.   

    [insert into `product_to_effect` (`product_id`, `effect_name`) values ('188', '关节炎') where not exists (select * from `product_to_effect` where `product_id`='188' and `effect_name`='关节炎')]如果product_id的类型是int你的写法应该是[insert into `product_to_effect` (`product_id`, `effect_name`) values (188, '关节炎') where not exists (select * from `product_to_effect` where `product_id`=188 and `effect_name`='关节炎')]
      

  3.   

    where not exists(select *from where `列名` not exists(select *from 
      

  4.   

    我也感觉应该是where 列名 not exists
      

  5.   

    insert into `product_to_effect` (`product_id`, `effect_name`) values (188, '关节炎') where not exists;如果是int类型的value值是不需要引号的,当是字符串的时候才需要引号