Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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
 
Old May 30th, 2005, 09:15 AM
Authorized User
 
Join Date: Jun 2003
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 Problem

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.

Code:
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
 
Old May 31st, 2005, 03:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

well it depends on exactly what you want to get in your resultset. If you only want fields from the members table then don't include any from membersproducts in the SELECT and add a GROUP BY for each of the members fields
 
Old June 1st, 2005, 02:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you are looking for display of just Membername, you can use DISTINCT Keyword in your select alternatively (if you are not using * or multiple columns there) and exclude the membersproducts.* from there.

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
convert a SQL Statement from MS Access to a SQL Corey Access 6 March 28th, 2007 12:33 PM
SQL select statement problem shrisangeeta Classic ASP Databases 3 June 15th, 2006 10:28 AM
sql statement problem thas123 SQL Server 2000 4 February 22nd, 2006 01:59 PM
SQL Statement Problem Ben Horne Access 11 February 4th, 2004 11:01 PM
help needed with a SQL select statement problem wslyhbb Java Databases 1 August 14th, 2003 07:30 AM





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