Hey this is much appreciated but you missed the mark on this one unfortunately. In MySQL the sets can either be inserted by name or by inserting a number that corresponds to the numeric value given that element that is in the set. For example:
In a table I have a field of type SET that is defined this way:
"Dog","Cat","Bird","Reptile","Horse","Fish"
MySQL allows you to either insert the set as one or many of the elements.
A person says they have a Dog, Cat and a Fish. So it can be inserted as a list: 'Dog','Cat','Fish'
The other way it can be inserted is by a number that represents the binary value. MySQL assigns a numberic value to each of the set's elements like so:
"Dog" => 1, "Cat" => 2, "Bird" => 4, "Reptile" => 8, "Horse" => 16, "Fish" => 32
Basically it's like a bit flag. MySQL allows up to 64 elements in a set. So if I were to insert by number I would add up the values for the elements. 1+2+4 = 7, when you insert 7, MySQL takes it as inserting 'Dog','Cat','Bird'.
It's like using a binary flag.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.