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 6th, 2014, 12:31 AM
Friend of Wrox
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get data from 3 different tables?

Hello all!

I`m trying to make a query which will bring me records from 3 different tables. The first table is named "customers", the second "drugs" and the third "surgery".
From the first table I`ll print out a single record but from the second and the third table I want to print out all the records that match with the "customers.name" and "customers.petname" fields with the "drugs.name", "drugs.petname" and "surgery.name". "surgery.petname".

When I print out the data from the first table everything is ok. Then I try to insert "customers.name" to a variable make a query for the second table. But there I get an error.

The error is :
Microsoft OLE DB Provider for ODBC Drivers (0x80040E10) Too few parameters. Expected 1.

dim customer
customer= rsGuestbook("name")

strSQL1 = "SELECT * FROM drugs WHERE name = " & customer & "
I tried the "response.write strSQL1" and I got back
Select * FROM drugs WHERE name = John Smith
Old January 6th, 2014, 10:04 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

You need to enclose strings in single quotes:

Select * FROM drugs WHERE name = 'John Smith'
Hope this helps,

Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Old January 8th, 2014, 12:28 PM
Friend of Wrox
Join Date: May 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts

thank you Imar. You were right! It worked...

Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting data from link tables psnow1985 SQL Server ASP 0 March 27th, 2008 03:19 PM
how to compare tables data ramanadyv SQL Language 0 April 10th, 2006 04:38 AM
Getting data from two tables pajer SQL Server 2000 8 September 30th, 2004 10:45 AM
Getting data from tables MattLeek Access VBA 2 October 8th, 2003 11:22 AM
data retrieve from three tables mateenmohd SQL Server 2000 2 October 7th, 2003 04:26 AM

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