Senbon Senbon - 3 months ago 8
SQL Question

ASP.NET SQL regarding the statement

I have a table with columns

Type
,
HalfYearPrice
,
FullYearPrice
.

On the form I have 2 radiolists, one each for
Type
and
Price
.

Say if a person chooses the type, then chooses the
HalfYearPrice


I'm stuck on how to write the SQL statement. Currently I got

SELECT *
FROM product
WHERE Type = @type
AND *something* = @price


Where
@type
and
@price
are selected values from radiolists.

But what do I put in place of something as it could be either table column HalfYearPrice or FullYearPrice

Answer

To search HalfYearPrice and FullYearPrice at the same time, use IN:

SELECT * 
FROM product 
WHERE Type = @type 
  AND @price in (HalfYearPrice, FullYearPrice)
Comments