INSERT INTO X 2 - Differences

Codes here !

Moderators: gesf, Michalio

Post Reply
User avatar
NorseMan
php-forum Fan User
php-forum Fan User
Posts: 65
Joined: Mon Jul 04, 2022 5:25 pm
Location: Near Oslo (Norway)

What exactly is the differences between these two? Does it depend on when to use them or is it the same when to use? Do they do, act, and preform the same?

INSERT INTO tableName SET
column1Name = column1Value
column2Name = column2Value

INSERT INTO tableName
(column1Name, column2name)
VALUES (column1Value, column2Value)
________________
Leon (Norway)
________________

-------
(some of)My configuration is:
Laragon full 5.0 web server with PHP and MySQL installation
(Apache 2.4.47 / PHP 7.4.19 / MySQL 5.7.33)
-------
My toolbox and workbench:
Navicat for MySQL 16.0.13
FileZilla 3.57.1
Among others
-------
Development toolbox:
Adobe DreamWeaver 21.2
Adobe Photoshop 23.1.0
Adobe Illustrator 26.0.2
Adobe InDesign 17.0.1
Adobe XD
Visual Studio Code 1.63.2 (with some extensions enabled)
User avatar
Michalio
Moderator
Moderator
Posts: 337
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

Are we talking about mysql only?
The first version is mire readable, but the second is preffered as a valid sql implementation. But generally it should works the same
Free coding lessons: https://php-forum.com/phpforum/viewtopic.php?t=29852
User avatar
NorseMan
php-forum Fan User
php-forum Fan User
Posts: 65
Joined: Mon Jul 04, 2022 5:25 pm
Location: Near Oslo (Norway)

Michalio wrote: Tue Jul 05, 2022 10:27 am Are we talking about mysql only?
As written and asked, MySQL only
________________
Leon (Norway)
________________

-------
(some of)My configuration is:
Laragon full 5.0 web server with PHP and MySQL installation
(Apache 2.4.47 / PHP 7.4.19 / MySQL 5.7.33)
-------
My toolbox and workbench:
Navicat for MySQL 16.0.13
FileZilla 3.57.1
Among others
-------
Development toolbox:
Adobe DreamWeaver 21.2
Adobe Photoshop 23.1.0
Adobe Illustrator 26.0.2
Adobe InDesign 17.0.1
Adobe XD
Visual Studio Code 1.63.2 (with some extensions enabled)
User avatar
Michalio
Moderator
Moderator
Posts: 337
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

If you create a script for small purpose then you can use the more readable option (insert ... set), but for the app where you want to use database as option behind the abstraction/facade then you should use the sql version (insert ... values). The performance should be the same, but you can check it by inserting 10000 or more records and compare the time, it should be almost the same
Free coding lessons: https://php-forum.com/phpforum/viewtopic.php?t=29852
Post Reply