![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
My Insert statement looks like INSERT INTO tableName Column1Name, Column2Name VALUES ('c1', 'c2'); Shouldn't the UPDATE statement look very similar? UPDATE TableName Column1Name, Column2Name VALUES ('c1', 'c2') WHERE something=something; It appears that the update has a different structure or I've messed up somewhere else... UPDATE TableName Column1Name=`c1`, Column2Name=`c2` WHERE something=something; Is what the tutorial says, but shouldn't my first UPDATE statement work as well? |
#3
| |||
| |||
|
|
My Insert statement looks like INSERT INTO tableName Column1Name, Column2Name VALUES ('c1', 'c2'); Shouldn't the UPDATE statement look very similar? UPDATE TableName Column1Name, Column2Name VALUES ('c1', 'c2') WHERE something=something; It appears that the update has a different structure or I've messed up somewhere else... UPDATE TableName Column1Name=`c1`, Column2Name=`c2` WHERE something=something; Is what the tutorial says, but shouldn't my first UPDATE statement work as well? |
#4
| |||
| |||
|
|
On Mar 16, 4:32*pm, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: My Insert statement looks like INSERT INTO tableName Column1Name, Column2Name VALUES ('c1', 'c2'); Shouldn't the UPDATE statement look very similar? UPDATE TableName Column1Name, Column2Name VALUES ('c1', 'c2') WHERE something=something; It appears that the update has a different structure or I've messed up somewhere else... UPDATE TableName Column1Name=`c1`, Column2Name=`c2` WHERE something=something; Is what the tutorial says, but shouldn't my first UPDATE statement work as well? No. Everything is not the same as everything else. As it happens, MySQL supports a non-standard INSERT ... ON DUPLICATE KEY UPDATE ... type statement "REPLACE INTO...". I say "type statement" because its effect is not always the same as an equivalent INSERT ... ON DUPLICATE KEY UPDATE ... It also supports a non standard INSERT syntax using SET (so that INSERT looks more like an UPDATE statement as opposed to vice versa). Of course all of this is in the manual so I'm not sure why you asked here in the first place. |
#5
| |||
| |||
|
|
On Mar 16, 11:14*am, Captain Paralytic <paul_laut... (AT) yahoo (DOT) com> wrote: On Mar 16, 4:32*pm, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: My Insert statement looks like INSERT INTO tableName Column1Name, Column2Name VALUES ('c1', 'c2'); Shouldn't the UPDATE statement look very similar? UPDATE TableName Column1Name, Column2Name VALUES ('c1', 'c2') WHERE something=something; It appears that the update has a different structure or I've messed up somewhere else... UPDATE TableName Column1Name=`c1`, Column2Name=`c2` WHERE something=something; Is what the tutorial says, but shouldn't my first UPDATE statement work as well? No. Everything is not the same as everything else. As it happens, MySQL supports a non-standard INSERT ... ON DUPLICATE KEY UPDATE ... type statement "REPLACE INTO...". I say "type statement" because its effect is not always the same as an equivalent INSERT ... ON DUPLICATE KEY UPDATE ... It also supports a non standard INSERT syntax using SET (so that INSERT looks more like an UPDATE statement as opposed to vice versa). Of course all of this is in the manual so I'm not sure why you asked here in the first place. If a table has two columns that must be unique, how do you know which of the two columns is the one that is not unique during the UPDATE/ INSERT? |
#6
| |||
| |||
|
|
On Mar 16, 11:14*am, Captain Paralytic <paul_laut... (AT) yahoo (DOT) com> wrote: On Mar 16, 4:32*pm, SpreadTooThin <bjobrie... (AT) gmail (DOT) com> wrote: My Insert statement looks like INSERT INTO tableName Column1Name, Column2Name VALUES ('c1', 'c2'); Shouldn't the UPDATE statement look very similar? UPDATE TableName Column1Name, Column2Name VALUES ('c1', 'c2') WHERE something=something; It appears that the update has a different structure or I've messed up somewhere else... UPDATE TableName Column1Name=`c1`, Column2Name=`c2` WHERE something=something; Is what the tutorial says, but shouldn't my first UPDATE statement work as well? No. Everything is not the same as everything else. As it happens, MySQL supports a non-standard INSERT ... ON DUPLICATE KEY UPDATE ... type statement "REPLACE INTO...". I say "type statement" because its effect is not always the same as an equivalent INSERT ... ON DUPLICATE KEY UPDATE ... It also supports a non standard INSERT syntax using SET (so that INSERT looks more like an UPDATE statement as opposed to vice versa). Of course all of this is in the manual so I'm not sure why you asked here in the first place. If a table has two columns that must be unique, how do you know which of the two columns is the one that is not unique during the UPDATE/ INSERT? |
#7
| |||
| |||
|
|
If a table has two columns that must be unique, how do you know which of the two columns is the one that is not unique during the UPDATE/ INSERT? |
#8
| |||
| |||
|
|
My Insert statement looks like INSERT INTO tableName Column1Name, Column2Name VALUES ('c1', 'c2'); Shouldn't the UPDATE statement look very similar? |
#9
| |||
| |||
|
|
On 3/16/2011 9:32 AM, SpreadTooThin wrote: My Insert statement looks like INSERT INTO tableName Column1Name, Column2Name VALUES ('c1', 'c2'); Shouldn't the UPDATE statement look very similar? * * No, but the REPLACE statement does. *Check that out. * * * * * * * * * * * * * * * * * * * * John Nagle |
![]() |
| Thread Tools | |
| Display Modes | |
| |