diff options
| author | Francesco Borzì <borzifrancesco@gmail.com> | 2021-02-07 18:42:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-07 18:42:27 +0100 |
| commit | 138a9f6bbcbb5a990942dd1c9606b7d5f37ee295 (patch) | |
| tree | 1224acdad68ae9e33a3fd716ee61a860717d39a9 /docs | |
| parent | 24b4babab5013286c194e3052b878c462c077427 (diff) | |
| download | wiki-138a9f6bbcbb5a990942dd1c9606b7d5f37ee295.tar.gz wiki-138a9f6bbcbb5a990942dd1c9606b7d5f37ee295.tar.bz2 wiki-138a9f6bbcbb5a990942dd1c9606b7d5f37ee295.zip | |
docs(sql): example SQL variable (#397)
* docs(sql): example SQL variable
* Update Dealing-with-SQL-files.md
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/Dealing-with-SQL-files.md | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/docs/Dealing-with-SQL-files.md b/docs/Dealing-with-SQL-files.md index ded1f9d..8af93fe 100644 --- a/docs/Dealing-with-SQL-files.md +++ b/docs/Dealing-with-SQL-files.md @@ -74,7 +74,24 @@ Good: UPDATE `table_1` SET `field_1` = 'someValue' WHERE `entry` IN (1000, 2000, 3000); ``` -### Flags +## Use variables when necessary + +SQL variables help to make IDs/GUIDs more manageable, use them when needed: + +```sql +SET @FREE_GUID:=145211; + +DELETE FROM `creature` WHERE `guid` BETWEEN @FREE_GUID AND @FREE_GUID+5; +INSERT INTO `creature` VALUES +(@FREE_GUID+0, 1420, 530, 6785.898, -7607.692, 128.1121, 3.815103, 120, 0), +(@FREE_GUID+1, 1420, 530, 6753.482, -7647.198, 128.3187, 3.793595, 120, 0), +(@FREE_GUID+2, 2914, 530, 6830.517, -7396.761, 46.36444, 2.204267, 120, 0), +(@FREE_GUID+3, 2914, 530, 6967.708, -7464.932, 47.05861, 1.433785, 120, 0), +(@FREE_GUID+4, 2914, 530, 6764.093, -7363.276, 50.46708, 2.048597, 120, 0), +(@FREE_GUID+5, 2914, 530, 6703.647, -7402.308, 51.60884, 5.743487, 120, 0); +``` + +## Flags For flags (2^) columns, when you remove or add a flag, it is better not to override the existing value as flags are combined values. |
