need 2 simple MYSQL errors fixed

Discussion in 'Programming' started by toycat, Feb 18, 2009.

  1. #1
    Database error: Invalid SQL: INSERT INTO user_deleted SELECT * FROM user WHERE userid='6529'
    MySQL Error: 1136 (Column count doesn't match value count at row 1)
    Session halted.

    need help fixing that, will pay $10 if you can step by step guide me through this
    MSN ID:
     
    toycat, Feb 18, 2009 IP
  2. tures

    tures Peon

    Messages:
    172
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    ive added you to MSN
     
    tures, Feb 18, 2009 IP
  3. Marc Fraser

    Marc Fraser Peon

    Messages:
    283
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    Has this been done? If not, I'll be sure to fix it...

    You cant have Insert Into and Select in the same command..
     
    Marc Fraser, Feb 19, 2009 IP
  4. fabriciogr

    fabriciogr Active Member

    Messages:
    958
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    73
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #4
    was this sorted? i use INSERT INTO table1 SELECT from table2 queries almost everyday and should be able to find the issue
     
    fabriciogr, Feb 19, 2009 IP
  5. L3G10N

    L3G10N Well-Known Member

    Messages:
    370
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    158
    As Seller:
    100% - 0
    As Buyer:
    100% - 2
    #5
    If it wasn't sorted I can be of assistance as well..
     
    L3G10N, Feb 19, 2009 IP
  6. austin-G

    austin-G Peon

    Messages:
    435
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #6
    No, you can use that. The problem is that the columns don't match. If you do INSERT INTO table_a SELECT * FROM table_b WHERE x, table_a must have the same columns as table_b.
     
    austin-G, Feb 19, 2009 IP
  7. G.B.Yahav

    G.B.Yahav Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #7
    If the colums dont count it means that you have someting like this

    TBL1 - Members: {id, name, pass, email}
    TBL2 - Groups: {id, name, administrator_accross}
    and them you try to do someting like this

    INSERT INTO Groups VALUES SELECT * FROM `Members` WHERE `id`= '1'
    so the colums dont match.. anyway i dont recomened you to use SELECT inside INSERT

    and to tell the truth, i didnt see anyone who do that i dont think its "leagal expression"... butdidnt check it myself....

    anyway, good luck :)
     
    G.B.Yahav, Feb 19, 2009 IP
  8. toycat

    toycat Well-Known Member

    Messages:
    2,304
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    150
    As Seller:
    100% - 1
    As Buyer:
    100% - 0
    #8
    Thing is, this was working fine till about a week ago when it jst stopped ( idnd't change script)
     
    toycat, Feb 20, 2009 IP
  9. fabriciogr

    fabriciogr Active Member

    Messages:
    958
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    73
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #9
    hmm... if you haven't changed a thing neither in the database nor the code then its something with to do with the data. maybe some data is not being espaced properly and it's considering as another column and they no longer match.

    i'd need to look into the query and all the data you're trying to do this with
     
    fabriciogr, Feb 20, 2009 IP