LearnItFirst User Forum

SQL Server 2008 SSAS Training Videos
Welcome Guest Search | New Posts | Members | Log In | Register

Multiple conditions in sql query Options
abrars
Posted: Sunday, May 24, 2009 5:40:35 AM
Rank: Newbie

Joined: 5/24/2009
Posts: 1
Points: 3
Where do you live?: aus
I have a table DVD where i have columns

dvdid
title
summary
price
due
classification --- G , PG , M etc
Status -- > Available or Not Available

I have to write a query where user enter the title in the search (like % )
the result displayed should meet this following condition

a) Status -- should be avaliable only DVD with status Availabe should be displayed

b) The classification should be G or PG --> other classification types are restricted

the query I was trying was as below ..

Code:

SELECT [DVDID], [Title], [Released], [Summary], [Status],[Due] FROM [DVD] WHERE ([Title] LIKE '%' + ? + '%') and ([Status] = 'Available')')


Now I am struggling to include the another condition where classification

How can I validate that condition. I tried using multiple select condition but I am not acheive the task.

Please help me. I am using access database

Thanks in Advance
Reply With Quote
Scott Whigham
Posted: Sunday, May 24, 2009 8:59:38 AM


Rank: Super Mod

Joined: 3/20/2006
Posts: 476
Points: 1,053
Where do you live?: Dallas, TX
Seems as though I don't understand the question - b/c what you've asked is too easy:
Code:
SELECT [DVDID], [Title], [Released], [Summary], [Status],[Due] FROM [DVD] WHERE ([Title] LIKE '%' + ? + '%') and ([Status] = 'Available')') AND Classification='PG'
See? I don't think I understand what you're asking.
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.