dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Problem with Search Records feature

  1. #1
    Join Date
    Aug 2002
    Location
    East of Pakistan , West of China
    Posts
    7

    Problem with Search Records feature

    I have a Find Form where I need to find the records of book titles based on a few parameters provided by the user.One of the params is Publisher Name. Now the problem is that the PublisherName is stored in a different table than the Titles table. The titles table simply contains the PID(publisher ID) of the Publisher. Now to perform a search on Titles based on parameters including the Publisher NAME, Im trying to use the following SQL statement, but this is giving me duplicate records. Any reason ? Any other way to solve the problem ?


    SELECT distinct Titles.ISBNNum, Titles.Name,Titles.PID,Titles.author,Titles.Edition ,Titles.Cost,Publisher.Name FROM Titles,Publisher WHERE
    ISBNNum LIKE @isbn AND
    Titles.Name LIKE @Name AND
    Author LIKE @Author AND _
    Titles.PID in
    (SELECT distinct PID FROM Publisher WHERE Name like @Publisher)


    There are 2 tables : Publisher and Titles

    Fields:
    Publisher-PID,PName, PAddress
    Titles-ISBNNum,Name,Price,Author,PID

  2. #2
    Join Date
    Aug 2002
    Location
    Germany
    Posts
    15
    Try DISTINCTROW instead of DISTINCT it is a little differences indialects if you use Microsoft Databases.
    Best regards
    Markus

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)