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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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.. |
|
|||
|
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' |
|
|||
|
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. |
|
|||
|
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.... |
|
|||
|
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 |
|
|||
|
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.. |
|
|||
|
> > > 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 |