July 25, 2005 at 6:13 am
I have a Table done is SQL 2000, and Im using ASP.net to program.
Draw Table.
Here are the colums below
DRAW_ID
DRAW_DATE
DRAW_NUMBER1
DRAW_NUMBER2
DRAW_NUMBER3
DRAW_NUMBER4
PRIZE_1
PRIZE_2
PRIZE_3
CREATE_DATE
UPDATE_DATE
I've actually have a page done in asp.net, where it will insert values into this Draw Table. So my DRAW_ID,DRAW_DATE,PRIZE_1,PRIZE_2,PRIZE_3,CREATE_DATE has some values.
Now I'm stuck. Since on another Page of my Site, I need to populate my Dropdownlists with DRAW_IDs. Since Im going to Generate some Lucky numbers and Store them
I do not know how to Query?. Since I need to Get All the DRAW_IDs which does not have any DRAW_NUMBERs...
Please help me out.
July 25, 2005 at 6:26 am
Are the DRAW_NUMBERs null? And do you need all of them to be null? Then try this:
select DRAW_ID from [Draw table] where
DRAW_NUMBER1 is null or
DRAW_NUMBER2 is null or
DRAW_NUMBER3 is null or
DRAW_NUMBER4 is null
July 25, 2005 at 6:32 am
Thanks it worked...
July 25, 2005 at 6:49 am
Raj if I read your original post correctly you want all the Draw_IDs where there are no values for any of the Draw_Nubers. Then using or in your select will not give you the results you want. Try this query
--if object_ID ('TEMPdb...Test') > 0
DROP TABLE Test
Create table Test
(
Draw_ID int identity(1,1),
Draw_Number1 int,
Draw_Number2 int,
Draw_Number3 int,
Draw_Number4 int,
Some_value int
--other stuff
)
insert into test(draw_number1,some_value) values(234,99)
insert into test(draw_number2) values(254)
insert into test(draw_number3) values(232)
insert into test(Some_value) values(99)
select * From Test
Where draw_Number1 is null
and Draw_Number2 is Null
and Draw_Number3 is Null
and Draw_Number4 is Null
--Returns Draw_ID 4
select * From Test
Where draw_Number1 is null
or Draw_Number2 is Null
or Draw_Number3 is Null
or Draw_Number4 is Null
--Returns Draw_IDs 1,2,3,4
HTH Mike
July 25, 2005 at 6:52 am
Mike, you are probably right
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply