Toggle navigation
Dashboard
Dashboard Tracker
Add / Edit My Forums
System Announcements
Discussion
Active Thread Feed
Top Threads Today
Top Threads This Week
Top Threads Library
Go!
View All
View All
Login
Logout
Home
Forums Index
Server Side
/
Databases
4:48 am May 21, 2026
This page requires javascript.
Forum Moderators:
open
Message Too Old, No Replies
Options for inserting and updating mysql
Options for inserting and updating mysql
drooh
Msg#:4331053
6:34 pm on Jun 25, 2011
(gmt 0)
Is it possible to do something like this?
$sql = "UPDATE `test` SET (`name`,`age`) VALUES ('Sam','34') WHERE `id` = 10";
It would be nice because the insert command is similar
$sql = "INSERT INTO `test` (`name`,`age`) VALUES ('Sam','34')";
drooh
Msg#:4331054
6:37 pm on Jun 25, 2011
(gmt 0)
Or vise versa, is there a way to
$sql = "INSERT INTO `test` (`name`='sam',`age`='34')";
coopster
Msg#:4335372
8:10 pm on Jul 5, 2011
(gmt 0)
Have you checked the optional syntax?
[
dev.mysql.com
...]
drooh
Msg#:4335390
8:51 pm on Jul 5, 2011
(gmt 0)
not really seeing an answer there? Can you specify some code or be more specific?
coopster
Msg#:4335396
9:06 pm on Jul 5, 2011
(gmt 0)
Second syntax example is almost exactly what you typed in your second post ...
INSERT INTO test SET name = 'sam', age = 34;
drooh
Msg#:4335413
9:35 pm on Jul 5, 2011
(gmt 0)
Ok, thank you, I wish they could write their examples like that. For some reason that mysql website is just so hard for me to read.
Somehow
INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
[INTO] tbl_name
SET col_name={expr | DEFAULT}, ...
[ ON DUPLICATE KEY UPDATE
col_name=expr
[, col_name=expr] ... ]
Just doesnt register in my brain.
thanks for you post and letting me know this is possible.
drooh
Msg#:4335446
11:04 pm on Jul 5, 2011
(gmt 0)
This was exactly what I was looking for, this way I can re-use a portion of the query for inserting and updating.
Just out of curiosity at this point, is there a way to do something like this?
$sql = "UPDATE `test` SET
(
`name`,
`age`
)
VALUES
(
'Pete',
'34'
)
WHERE `id` = 10
";
coopster
Msg#:4336321
12:32 pm on Jul 7, 2011
(gmt 0)
not according to the syntax ...
[
dev.mysql.com
...]
Regarding reading the manuals and understanding the syntax ...
[
dev.mysql.com
...]
Join The Conversation
Register
For Free! -
Become a
Pro Member
!
See forum categories
-
Enter the Forum
Moderators and Top Contributors
Moderator List
| Top Contributors:
This Week
,
This Month
,
Apr
,
Mar
,
Archive
,
Top 100 All Time
,
Top Voted Members
Hot Threads This Week
May 2026 Google Search Observations
AdSense Earnings and Observations - May 2026
AI visibility audit
Adsense / Personal Manager / Support
Hacker spoofing as GoogleBot
Page indexed but live url test gets 500 error
Link collaboration strategies
in case you missed it .
Microsoft, AS8075. Google, AS396982.
Bad actor claiming to be OpenAi
Home
Forums Index
Server Side
/
Databases
4:48 am May 21, 2026