View Single Post

  #4 (permalink)  
Old 07-23-2007
maya
 
Posts: n/a
Default Re: problems with 'insert' command...

ZeldorBlat wrote:
> On Jul 23, 10:38 am, maya <maya778...@yahoo.com> wrote:
>> 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..

>
> What's confusing about that?
>
> insert into pb
> set caption='six',
> photo=6,
> blog='1'
>

sorry, can't go from

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
>> [INTO] tbl_name
>> SET col_name={expr | DEFAULT}, ...
>> [ ON DUPLICATE KEY UPDATE col_name=expr, ... ]


to

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


as easily as you can....;)

either way, this, then..
> insert into pb
> set caption='six',
> photo=6,
> blog='1'


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....

Reply With Quote