+ Reply to Thread
Results 1 to 6 of 6

Thread: retrieve values

  1. #1
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    510
    Rep Power
    3

    retrieve values

    Hi,

    I have a field called Options

    The values in the field are stored like this

    Easy to access, Somewhat easy, Very hard

    How can i find the count of "somewhat easy" in this field

    todd

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    What database are you using?
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    510
    Rep Power
    3

    sql server

  4. #4
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Washington, D.C.
    Posts
    2,347
    Blog Entries
    9
    Rep Power
    19

    Okay, I think it can be done if you use a stored procedure with some TSQL. However, I encourage you to rethink your database design. This does not follow database normalization rules.

    Instead of a comma delimited field, create another table that will create a relationship with the values you are storing and the record.

    For example, let's say you have the following tables:

    Users:
    userid username password

    UserGroups:
    groupid groupname permissions

    To allow a user to be a member of multiple groups you would have the following table:

    UsersInGroups:
    ugpid userid groupid

    Then you can more easily and efficiently do any type of query against the data with the help of joins to get the desired result. I suggest you do the same with your database.
    jmurrayhead
    If you agree, give me rep. If my post helped you, click "Thanks".
    If you like it here...throw us a few bones to help support us.


  5. #5
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    1,037
    Blog Entries
    2
    Rep Power
    13

    I take it to mean that the field can be one of 3 values, Easy, Sorta, Hard (or whatever). However, I wouldn't do it this way either, but add the other table with 3 records and a PK of 1,2,3. Then in the parent table, the field either has a value of 1, 2 or 3. So the count becomes:
    Code:
    SELECT COUNT(1) FROM daTable where daField = 2
    
    Wolffy
    ------------------------
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.

  6. #6
    Wolfmaster Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy is a splendid one to behold Wolffy's Avatar
    Join Date
    Mar 2008
    Location
    Peoria, IL
    Posts
    1,037
    Blog Entries
    2
    Rep Power
    13

    OK, on third read, I've changed my mind. One of the basic rules of relational databases is the a filed can have only 1 value. So you should create a table for storing your three options -- same advice as in my last post.
    Wolffy
    ------------------------
    Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary.

+ Reply to Thread

Similar Threads

  1. Store Calculated Values (Updating Fields)
    By sbenj69 in forum Access Database Samples
    Replies: 9
    Last Post: January 12th, 2009, 11:49 AM
  2. Replies: 8
    Last Post: June 17th, 2008, 09:39 AM

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

SEO by vBSEO