Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 30th, 2005, 06:41 PM
Authorized User
 
Join Date: Jun 2003
Location: Melbourne, Victoria, Australia.
Posts: 90
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to tdaustin Send a message via Yahoo to tdaustin
Default SQL Statement problems

Hi All,

Im trying to write a sql statement for a search feature which contains 2 relational tables.

Im am getting the right data ok, but getting duplicate records of the main table if 2 or more items in the second table matches

How do i only get it to only output the member once if say 2 of his products match the search phase.


strSQL = "SELECT members.*, membersproducts.* FROM members, membersproducts WHERE (membersproducts.Product LIKE '%"& keywords &"%') AND members.SupplierID = membersproducts.SupplierID ORDER BY members.SupplierID DESC LIMIT "& pagenum &","& results &""



so for example member "tim" has two products product1, product2 and the keyword was product my result would be
tim
tim

how do i get on to be displayed once

Thanks

Tim :)



TDA

TDA
__________________
TDA
  #2 (permalink)  
Old May 30th, 2005, 07:16 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

You could throw a DISTINCT in there - EG:
strSQL = "SELECT DISTINCT(members.name,...

This should also work:

strSQL = "SELECT members.*, membersproducts.* FROM members
LEFT OUTER JOIN membersproducts ON members.SupplierID = membersproducts.SupplierID
WHERE (membersproducts.Product LIKE '%"& keywords&"%') ORDER BY
members.SupplierID DESC LIMIT "& pagenum &","&
results &""

Wind is your friend
Matt


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems using case statement in where clause vghiya SQL Server 2000 3 May 28th, 2007 05:12 AM
IF statement problems - please help ivanv Classic ASP Basics 2 August 31st, 2006 03:10 AM
IF statement problems - please help ivanv ASP.NET 1.0 and 1.1 Basics 1 August 28th, 2006 07:40 AM
Problems with my Insert Statement brendan82 Access 1 January 6th, 2004 08:30 AM
Problems with my Insert Statement brendan82 Beginning VB 6 1 January 6th, 2004 08:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.