Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    416
    Thanks
    18
    Thanked 26 Times in 26 Posts

    Selecting mysql column with type SET

    I have a column of type SET with a list of variables. I know that SET is based on a list and saved as a binary, or something of the sort. I can update the list using a decimal (3 means the first and second item, 7 means the first, second, and third item, etc.) however I want to select the data in the same way so I can do a binary conversion on it later (ex. if($data & 2)) but I don't want to have to convert it with PHP.

    Basically, I want to grab a row from the database, and if the column type is SET, then I want the value of that column to be in decimal form of the data. Any tips?

    If I can do it by the column type being SET rather than specifying each name that would be great as well, but it's not that important.
    Last edited by Dubz; 06-14-2014 at 08:05 AM.
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    416
    Thanks
    18
    Thanked 26 Times in 26 Posts
    I've accomplished this by using the following query:
    PHP Code:
    $query 'SELECT *,  `col1`+0 AS `col1`, `col2`+0 AS `col2` FROM...'
    This way the data is returned in binary form and overrides the original value. The only other thing that would be nice is if I could do it by type SET instead of specifying the names, but this will do for now.
    If I've helped you out, show your appreciation by clicking the "Thanks" link as well as a link below!

    AdFly
    Facebook | Twitter
    Google | YouTube


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •