 |
| 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
|
|
|
|

January 27th, 2005, 06:46 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 27th, 2005, 06:58 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

January 27th, 2005, 07:06 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
SELECT trip_id, COUNT(*) AS total FROM trip_master GROUP BY trip_id HAVING total > 2;
Can that work in ASP?
|
|

January 27th, 2005, 07:07 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 27th, 2005, 07:09 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sorry. the table name isnt trip_master. Its trip_details
|
|

January 27th, 2005, 07:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

January 27th, 2005, 07:27 AM
|
|
Friend of Wrox
|
|
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
whats adCmdText?
|
|

January 27th, 2005, 07:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|
 |