Execute a Query

Type: Effect

Syntax:

[sqlsk] mysql %database object% [query|cmd|command] %query%

Examples:

Creating a table

set {_db} to mysql conn for "localhost;minecraft;admin;secretpass"
mysql {_db} query "CREATE TABLE IF NOT EXISTS `kings` (`kingid` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` TEXT)"
// This created table named "kings" with columns kingid and name
// AUTO_INCREMENT attribute can be used to generate a unique identity for new rows
// PRIMARY KEY constraint uniquely identifies each record in a table.

Insert data to table

set {_db} to mysql conn for "localhost;minecraft;admin;secretpass"
mysql {_db} query "INSERT INTO `kings`(`kingid`,`name`) VALUES (NULL,'ProXEQ')"

Update value in table

set {_db} to mysql conn for "localhost;minecraft;admin;secretpass"
mysql {_db} query "UPDATE `kings` SET `name`='Notch' WHERE `kingid` = '1'"

Last updated