SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast rad2004's Avatar
    Join Date
    Aug 2004
    Location
    UK
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Which column type is more suitable?

    The idea is to make the search on this table as fast and efficient as possible.

    Scenario:
    User A can choose a number from 1 to 8 (which would correspond to say 8 different colors) in column1, column2, column3 ...

    User B would then be running a query looking for users which, for example, selected any one of the values 1,2,3,4,5.

    My question is whether I should define this column TINYINT and then do a SELECT * FROM table WHERE column1 IN (1) AND column2 IN (2,3,4) AND column3 IN (2,5,6,7) etc.

    OR

    define the column as SET ('1','2','3','4','5','6','7','8') - even though the user would only select one value, and then do SELECT * FROM table WHERE column1 & 1 AND column2 & 3 AND column3 & 8 etc.

    Thanks,

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,323
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    tinyint
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •