Go Back   EQEmulator Home > EQEmulator Forums > Development > KayotRO

KayotRO This is the forum for Kayot's Editor.

Reply
 
Thread Tools Display Modes
  #1  
Old 04-08-2007, 01:06 AM
Kayot
Discordant
 
Join Date: Sep 2006
Location: Subsection 185.D354 C.12
Posts: 346
Default Wiki - SQL Commands

I'm putting this guide here so as to not lose it. This was a chat involving samandhi, ndnet, and myself. The chat involved SQL syntax and bitmask, which till now bitmasks were elusive to me. Bitmask work on interesting terms.

ndnet wrote the bitmask part, I already understood the basic idea, but this model really helps.

Example -

Code:
Select * From table;
Desc - This puts up all the tables, let assume one bitmask field. In this example there is only 5 entry's.

Code:
     +------+
     | mask |
     +------+
     | 5 | <--- 0101 = 0 + 4 + 0 + 1 = 5
     | 2 | <--- 0010 = 0 + 0 + 2 + 0 = 2
     | 3 | <--- 0011 = 0 + 0 + 2 + 1 = 3
     | 8 | <--- 1000 = 8 + 0 + 0 + 0 = 8
     | 4 | <--- 0100 = 0 + 4 + 0 + 0 = 4
     +------+
Goal - I want every line where the number 4 (or 0100) is turned on, this would include values 4 and five 5 because 4 = 0100, and 5 = 0101. Both have the number 4 bit turned on.

Code:
Select * From table where mask & 4;
Result:
Code:
     +------+
     | mask |
     +------+
     | 5 | <--- 0101 = 0 + 4 + 0 + 1 = 5
     | 4 | <--- 0100 = 0 + 4 + 0 + 0 = 4
     +------+
But what if I don't want 4's? What if I want everything but 4's?

Code:
Select * from table where not mask & 4;
Code:
     +------+
     | mask |
     +------+
     | 2 | <--- 0010 = 0 + 0 + 2 + 0 = 2
     | 3 | <--- 0011 = 0 + 0 + 2 + 1 = 3
     | 8 | <--- 1000 = 8 + 0 + 0 + 0 = 8
     +------+
And thats all about bitmaks, a list of operators;

Code:
BINARY Cast a string to a binary string
BIT_AND() Return bitwise and
BIT_COUNT() Return the number of bits that are set
BIT_LENGTH() Return length of argument in bits
BIT_OR() Return bitwise or
BIT_XOR() Return bitwise xor
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
/ Division operator
__________________
If at first you don't succeed destroy all evidence that you ever tried.

God doesn't give second chances... Hell, he sets you up the first time.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 11:58 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3