473,387 Members | 1,497 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Enum and Database question

What would be the Select Query for the following case.
I scratch my head but i'm only loosing my hair so far.

2 Records in tables
table Person

[Name] [FavSports]
Nicolas 12
Frank 2
John 10
Those entries and specialy the FavSports are based on an enum with
FlagsAttibute which allow multiple choice
<FlagsAttribute()> _
public enum Sports
None = 0
Soccer = 1
Tennis = 2
Hockey = 4
Swimming = 8
Football = 16
end enum

Now I want to retrive from the database all person who have Tennis (2) as
their favorite sport

SELECT * FROM Person WHERE FavSport = ?????? ORDER BY Name Asc;

I shoul get Frank and John

So what who be the routin to get the proper SELECT Statement

Thanks a lot for the help


Mar 10 '06 #1
2 1672
"Nicolas" <nl*****@hotmail.com> schrieb
What would be the Select Query for the following case.
I scratch my head but i'm only loosing my hair so far.

2 Records in tables
table Person

[Name] [FavSports]
Nicolas 12
Frank 2
John 10
Those entries and specialy the FavSports are based on an enum with
FlagsAttibute which allow multiple choice
<FlagsAttribute()> _
public enum Sports
None = 0
Soccer = 1
Tennis = 2
Hockey = 4
Swimming = 8
Football = 16
end enum

Now I want to retrive from the database all person who have Tennis
(2) as their favorite sport

SELECT * FROM Person WHERE FavSport = ?????? ORDER BY Name Asc;

I shoul get Frank and John

So what who be the routin to get the proper SELECT Statement

Thanks a lot for the help

"SELECT * FROM Person WHERE (FavSport & @mask) = @mask ORDER BY Name Asc;"

Set the value of Parameter "@mask" to Sports.Tennis. Or CInt(Sports.Tennis).
Armin

Mar 10 '06 #2
Thanks a lot
it's great
"Armin Zingler" <az*******@freenet.de> wrote in message
news:e6****************@tk2msftngp13.phx.gbl...
"Nicolas" <nl*****@hotmail.com> schrieb
What would be the Select Query for the following case.
I scratch my head but i'm only loosing my hair so far.

2 Records in tables
table Person

[Name] [FavSports]
Nicolas 12
Frank 2
John 10
Those entries and specialy the FavSports are based on an enum with
FlagsAttibute which allow multiple choice
<FlagsAttribute()> _
public enum Sports
None = 0
Soccer = 1
Tennis = 2
Hockey = 4
Swimming = 8
Football = 16
end enum

Now I want to retrive from the database all person who have Tennis
(2) as their favorite sport

SELECT * FROM Person WHERE FavSport = ?????? ORDER BY Name Asc;

I shoul get Frank and John

So what who be the routin to get the proper SELECT Statement

Thanks a lot for the help

"SELECT * FROM Person WHERE (FavSport & @mask) = @mask ORDER BY Name Asc;"

Set the value of Parameter "@mask" to Sports.Tennis. Or

CInt(Sports.Tennis).

Armin

Mar 10 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael.McD | last post by:
HI, I'd like to wire an enum's properties to a table in a dB at runtime. Has any one here tried this? Is it possible? And if it is how is it done? Thanks in advance, Michael McDowell
5
by: Andrea Williams | last post by:
I'm working with C# and I'm setting up some ENUM's I have a data and Business layer. I'm declaring a common enum for the Data Layer. The UI layer references the Bus layer and the bus layer...
2
by: Stan | last post by:
Suppose there is class with enum public enum Color { Red = 20, Black = 13 } And suppose there is a method
6
by: giannik | last post by:
I have an Enum Structure Public Enum MyEnum EnumVal1=0 EnumVal2=1 EnumVal2=2 end enum I save in an access database this enum value as an integer (0=EnumVal1,
4
by: Steve Teeples | last post by:
Given this definition of an enum: enum MyEnum { d1=1, d2=2 } Is there a way to dynamically create this same enum at runtime? I want to
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.