SQL Query Help


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: SQL Query Help

  1. #1
    Join Date
    May 2009
    Posts
    4

    SQL Query Help

    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.

    Thanks in Advance

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Try:

    WHERE ([Title] LIKE '%' + ? + '%') and ([Status] = 'Available') and ([Classification] IN ('G','PG')))
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    May 2009
    Posts
    4
    I tried its not working

    Any other suggestion please

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    How is it not working? Do you get an error? If do, what does the error say? What kind of database is it? What is the data type of the Classification column?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    May 2009
    Posts
    4
    The query is not returning the records, The database has records which match this condition,

    The query returns empty record

    Iam using Access database

    please help me out that will be great.

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    What is the data type of the Classification column?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  7. #7
    Join Date
    May 2009
    Posts
    4
    your code solved the problem. its working

    Thanks you made my problem easy.

Similar Threads

  1. Replies: 0
    Last Post: 11-30-2006, 06:58 AM
  2. SQL2000 remote SQL query
    By lightningtechie in forum Database
    Replies: 1
    Last Post: 02-07-2006, 09:34 AM
  3. Return Query Estimate for SQL Server 2000
    By Daniel Reber in forum VB Classic
    Replies: 0
    Last Post: 09-16-2002, 03:50 PM
  4. SQL Query Fails on NT System
    By Ken D. in forum VB Classic
    Replies: 2
    Last Post: 09-04-2002, 12:25 AM
  5. IIF in SQL Query Analyzer
    By Jeff Johnson in forum Database
    Replies: 3
    Last Post: 04-30-2001, 03:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center