Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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 January 27th, 2005, 06:46 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default more than 2 records with the same ID

i have a mysql db.

table name='trip_master'

in there is a column called 'trip_id'

when there are more than 2 records with the same ID i want to display the AMOUNT in a number into a HTML table.

an example of a 'trip_id' is BT/Y5RSWY

any ideas?

Picco

__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old January 27th, 2005, 06:58 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

This query will get you the trip_id & total for that trip where there are more than 2 records...
Code:
SELECT trip_id, COUNT(*) AS total FROM trip_master GROUP BY trip_id HAVING total > 2;
Cheers,

Chris

 
Old January 27th, 2005, 07:06 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

SELECT trip_id, COUNT(*) AS total FROM trip_master GROUP BY trip_id HAVING total > 2;

Can that work in ASP?



 
Old January 27th, 2005, 07:07 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

My code is sitting like this:

set rs4=con.execute("SELECT trip_id, COUNT(*) AS total FROM trip_master GROUP BY trip_id HAVING total > 2;")

what do you reckon.

BTW, thanks for your help mate.

Picco

 
Old January 27th, 2005, 07:09 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

sorry. the table name isnt trip_master. Its trip_details

 
Old January 27th, 2005, 07:21 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Code:
set rs4=con.execute("SELECT trip_id, COUNT(*) AS total FROM trip_details GROUP BY trip_id HAVING total > 2;", , adCmdText)
Should be fine.

Cheers,

Chris

 
Old January 27th, 2005, 07:27 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

whats adCmdText?

 
Old January 27th, 2005, 07:35 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

It specifies that you are executing an SQL statement.
The default value is adCmdUnknown and means that ADO has to work out what you are trying to do before passing the command on to the db (this slows things down).

Best regards,

Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in updating records & finding records naveed77 VB How-To 1 January 16th, 2007 12:10 PM
SQL script to create a unique ID for records chubnut SQL Server 2000 1 October 16th, 2006 07:25 AM
'this.ID = id;' in class construction holf BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 October 6th, 2006 10:58 AM
Change id in address bar and see future records karib Beginning PHP 0 September 16th, 2005 02:46 AM
why not index.asp?id=1 can be www.myweb.com/?id=1 BurhanKhan Classic ASP Professional 11 September 6th, 2004 02:06 PM





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