Why is this statement wrong ??/

Discussion in 'PHP' started by jacka, Aug 15, 2007.

  1. #1
    I have a very small problem that I hope you will be able to help.

    I have searched for hours in internet and its driving my crazy !!

    I have a simple Table (called pn_quarkpag) in a mysql database, one field contains part_numbers and the other is page_numer, which is empty ( that should contian just numbers)

    All I want to do is use a simple command in mysql database to look for all occurences of a word like SRT1, SRT2, etc in part_number filed and insert a value of 10 in the page_number field.

    I am using:

    
    insert into pn_quarkpage (page_number) values (10)
    where part_number like 'SRT%' ;
    HTML:

    CAn you please tell me what am I doing wrong.
    Thanks
    Jacka
     
    jacka, Aug 15, 2007 IP
  2. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Yes, the insert statement is used to insert rows, not column values.

    You should use the update statement to do that...

    
    update pn_quarkpage set page_number = 10 where part_number like 'SRT%';
    
    Code (markup):
     
    ecentricNick, Aug 15, 2007 IP
  3. Wickedfingers

    Wickedfingers Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Are you getting any kind of error messages?
     
    Wickedfingers, Aug 15, 2007 IP
  4. jacka

    jacka Peon

    Messages:
    165
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Wowwwww, what a result.
    many thanks ecentricNick. It worked first time.

    Thanks for you too for looking at my problem so quickly.
    I was getting error in "where part_number like 'SRT%", but its solved now.
    Thats one command I will never forget.
    cheers mate
     
    jacka, Aug 15, 2007 IP
  5. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Your welcome!
     
    ecentricNick, Aug 15, 2007 IP