insert into t_music_downloadcount(music_id,userid,ip,phoneid,status,downloadstatus,downloadtime,successtime,username)values( '640', '(select userid from t_olebar_user where username ='张三')','111.193.169.58', '1', '2', '1','2010-09-27 18:45:04', '2010-09-27 18:45:04', '张三')

解决方案 »

  1.   

    提示什么,你将字段名加上``
    如username->`username`
      

  2.   

    ERROR:  syntax error at or near "张三"
    LINE 1: ...select userid from t_olebar_user where username ='张三...
                                                                 ^In statement:
    insert into t_music_downloadcount(music_id,userid,ip,phoneid,status,downloadstatus,downloadtime,successtime,username)values( '640', '(select userid from t_olebar_user where username ='北京金飞鸿首体店_001')','111.193.169.58', '1', '2', '1','2010-09-27 18:45:04', '2010-09-27 18:45:04', '北京金飞鸿首体店_001')
      

  3.   

    INSERT INTO t_music_downloadcount(music_id,userid,ip,phoneid,`status`,downloadstatus,downloadtime,successtime,username) 
    VALUES('640', (SELECT userid FROM t_olebar_user WHERE username ='张三'),
    '111.193.169.58', '1', '2', '1','2010-09-27 18:45:04', '2010-09-27 18:45:04', '张三')
      

  4.   

    insert into t_music_downloadcount(music_id,userid,ip,phoneid,status,downloadstatus,downloadtime,successtime,username)values( '640', '(select userid from t_olebar_user where username ="'张三'")','111.193.169.58', '1', '2', '1','2010-09-27 18:45:04', '2010-09-27 18:45:04', '张三')字符串里的单引号要 引号引起来。
    mysql> select "'a'";
    +-----+
    | 'a' |
    +-----+
    | 'a' |
    +-----+
    1 row in set (0.00 sec)mysql>
      

  5.   

    insert into t_music_downloadcount(music_id,userid,ip,phoneid,status,downloadstatus,downloadtime,successtime,username)
    select '640',userid,'111.193.169.58', '1', '2', '1','2010-09-27 18:45:04', '2010-09-27 18:45:04', '张三'
    from t_olebar_user where username ='张三'
      

  6.   

    select userid into vuserid from t_olebar_user where username ='张三';
    insert into t_music_downloadcount(music_id,userid,ip,phoneid,status,downloadstatus,downloadtime,successtime,username)values( '640',vuserid ,'111.193.169.58', '1', '2', '1','2010-09-27 18:45:04', '2010-09-27 18:45:04', '张三');这下错不了了吧。