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
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
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.
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.
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.
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.
Bookmarks