Bluehost.com Web Hosting $6.95

problems with 'insert' command...

This is a discussion on problems with 'insert' command... within the MySQL Database forums, part of the Database Forums category; what is wrong with this insert? insert into pb caption='six' WHERE photo=6 AND blog='1'; get error.. I ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-23-2007
maya
 
Posts: n/a
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..
Reply With Quote
  #2 (permalink)  
Old 07-23-2007
ZeldorBlat
 
Posts: n/a
Default Re: problems with 'insert' command...

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'

Reply With Quote
  #3 (permalink)  
Old 07-23-2007
Captain Paralytic
 
Posts: n/a
Default Re: problems with 'insert' command...

On 23 Jul, 15:38, 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..


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

Reply With Quote
  #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
  #5 (permalink)  
Old 07-23-2007
Rik
 
Posts: n/a
Default Re: problems with 'insert' command...

On Mon, 23 Jul 2007 17:55:12 +0200, maya <maya778899@yahoo.com> wrote:
> ZeldorBlat wrote:
>> On Jul 23, 10:38 am, maya <maya778...@yahoo.com> wrote:
>>> <snip insert,insert,insert...>


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


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

> +------+-------+---------+---------------------+
> | blog | photo | caption | WhenAdded |
> +------+-------+---------+---------------------+
> | 1 | 1 | one | 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..)


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

--
Rik Wasmus
Reply With Quote
  #6 (permalink)  
Old 07-23-2007
maya
 
Posts: n/a
Default Re: problems with 'insert' command...

Rik wrote:
> On Mon, 23 Jul 2007 17:55:12 +0200, maya <maya778899@yahoo.com> wrote:
>> ZeldorBlat wrote:
>>> On Jul 23, 10:38 am, maya <maya778...@yahoo.com> wrote:
>>>> <snip insert,insert,insert...>

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

>
> UPDATE is the key here, INSERT always inserts a new row (unless an ON
> DUPLICATE KEY UPDATE syntax is used).
>
>> +------+-------+---------+---------------------+
>> | blog | photo | caption | WhenAdded |
>> +------+-------+---------+---------------------+
>> | 1 | 1 | one | 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..)

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


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

Reply With Quote
  #7 (permalink)  
Old 07-25-2007
Geoff
 
Posts: n/a
Default Re: problems with 'insert' command...


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


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


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:16 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0