> For the complete documentation index, see [llms.txt](https://arinem.gitbook.io/sqlsk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://arinem.gitbook.io/sqlsk/docs/execute-a-query.md).

# Execute a Query

### Type: Effect

## Syntax:

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

## Examples:

Creating a table

```java
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

```css
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

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