SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Checkbox form selects from MySQL table column with datatype EM

    I have a database with a column of datatype EM (multiple selection, say apples, oranges, grapes)

    I want to have a form with checkboxes for those values (apples, oranges, grapes etc) so one can select a breakfast basket type that contains for example, oranges and grapes.

    It would pull from the database those baskets with those selection of fruits (specified in the column 'Fruits', which is a EM datatype column. (I have a multiple selection when entering the values for the column.)

    Can it be done? Should I make another table with FruitNames?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,015
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    which database system is this? i've never heard of "datatype EM"
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, I meant SET, MySQL column datatype.

    I have multiple values in the column. When entering a new row, I can choose multiple values for the column FruitsinBasket.

    Also, when I add a new fruit value to that column (so it can be selected from the dropdown list of multiple selection), all my other entries values disappear and I have to re-enter everything again.

    Please help!
    Thank in advance.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,015
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    my advice is to stay away from SET (and also ENUM)

    you should really have a separate one-to-many table, which allows one row per fruit per basket
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    which allows one row per fruit per basket
    The query from the customer's fruit selection page (checkboxes) would be similar, I suppose?

    Thanks for your advice, I'm reading more posts similar to mine and trying to figure this out...


Bookmarks

Posting Permissions

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