Professional Web Applications Themes

problems with 'insert' command... - MySQL

what is wrong with this insert? insert into pb caption='six' WHERE photo=6 AND blog='1'; get error.. I was told here you don't need "WHERE" in this query, so did insert into pb caption='six' photo=6 AND blog='1'; also get error... is there a way to find out what is wrong with this command? all this 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 'photo=6 AND blog='1'' ... is a bit vague.... please, is there a site with more CONCRETE examples of queries, insert, delete, ...

  1. #1

    Default problems with 'insert' command...

    what is wrong with this insert?

    insert into pb caption='six' WHERE photo=6 AND blog='1';
    get error..

    I was told here you don't need "WHERE" in this query, so did

    insert into pb caption='six' photo=6 AND blog='1';
    also get error...

    is there a way to find out what is wrong with this command?

    all this
    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 'photo=6
    AND blog='1'' ... is a bit vague....


    please, is there a site with more CONCRETE examples of queries, insert,
    delete, update, replace, etc...

    examples like this are confusing..
    INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    SET col_name={expr | DEFAULT}, ...
    [ ON DUPLICATE KEY UPDATE col_name=expr, ... ]

    thank you very much..
    maya Guest

  2. #2

    Default Re: problems with 'insert' command...

    On Jul 23, 10:38 am, maya <com> wrote: 

    What's confusing about that?

    insert into pb
    set caption='six',
    photo=6,
    blog='1'

    ZeldorBlat Guest

  3. #3

    Default Re: problems with 'insert' command...

    On 23 Jul, 15:38, maya <com> wrote: 

    That isn't an examle, it's a syntax diagram. And it doesn't mention
    "AND" in there anywhere.

    Captain Guest

  4. #4

    Default Re: problems with 'insert' command...

    ZeldorBlat wrote: 
    >
    > What's confusing about that?
    >
    > insert into pb
    > set caption='six',
    > photo=6,
    > blog='1'
    >[/ref]
    sorry, can't go from

    INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE] [/ref]

    to
     

    as easily as you can....;)

    either way, this, then.. 

    doesn't give me errors, but it's not what I want..
    I don't want 'set' b/c am not inserting a new set, but ONE value into a
    column that exists already.. to wit:

    +------+-------+---------+---------------------+
    | blog | photo | caption | WhenAdded |
    +------+-------+---------+---------------------+
    | 1 | 1 | one | 2007-07-06 10:22:49 |
    | 1 | 2 | two | 2007-07-06 10:22:49 |
    | 1 | 3 | " " | 2007-07-06 10:22:49 |
    | 1 | 4 | " " | 2007-07-06 10:22:49 |
    | 1 | 5 | " " | 2007-07-06 10:22:49 |
    | 1 | 6 | " " | 2007-07-06 10:22:49 |
    | 1 | 7 | " " | 2007-07-06 10:22:49 |
    | 1 | 8 | " " | 2007-07-06 10:22:49 |
    | 1 | 9 | " " | 2007-07-06 10:22:49 |
    | 1 | 10 | " " | 2007-07-06 10:22:49 |
    | 1 | 11 | " " | 2007-07-06 10:22:49 |

    I want to insert "six" (or whatever) into row where photo=6 ('photo' col
    being a tinyint, not a string..)
    (i.e., I want to REPLACE empty string with whatever I put in form for
    this photo..)


    thank you very much....

    maya Guest

  5. #5

    Default Re: problems with 'insert' command...

    On Mon, 23 Jul 2007 17:55:12 +0200, maya <com> wrote: [/ref][/ref]
     

    UPDATE is the key here, INSERT always inserts a new row (unless an ON
    DUPLICATE KEY UPDATE syntax is used).
     

    UPDATE pb SET caption = '<whatever you want>' WHERE id = 6

    --
    Rik Wasmus
    Rik Guest

  6. #6

    Default Re: problems with 'insert' command...

    Rik wrote: [/ref]

    >
    > UPDATE is the key here, INSERT always inserts a new row (unless an ON
    > DUPLICATE KEY UPDATE syntax is used).

    >
    > UPDATE pb SET caption = '<whatever you want>' WHERE id = 6
    >
    > --Rik Wasmus[/ref]

    thank you!!!! I appreciate the help....

    is there ANOTHER site (apart from mysql.com) with mysql tutorials, query
    examples, etc..??

    I don't want to post here every time I have a question..

    thanks again..

    maya Guest

  7. #7

    Default Re: problems with 'insert' command...

     

    http://www.w3schools.com/sql/default.asp
    i like this site for basic SQL syntax


    Geoff Guest

Similar Threads

  1. php insert command failure
    By Carlton in forum MySQL
    Replies: 7
    Last Post: July 11th, 02:21 AM
  2. #38870 [NEW]: Die on INSERT command using MSSQL_Query
    By howardt at calhounisd dot org in forum PHP Bugs
    Replies: 5
    Last Post: September 19th, 01:26 PM
  3. Help needed to modify DW 'Insert' command
    By Mintyman in forum Dreamweaver AppDev
    Replies: 2
    Last Post: September 13th, 10:34 AM
  4. more description of why i need bulk insert command for vb?
    By Trint in forum Microsoft SQL / MS SQL Server
    Replies: 5
    Last Post: August 6th, 01:03 AM
  5. bulk insert command for vb?
    By Trint in forum Microsoft SQL / MS SQL Server
    Replies: 2
    Last Post: August 5th, 03:42 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139