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 April 1st, 2006, 06:55 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default inner join?

Hei!

I have to tables; tblProdukt and tblBestilling. TblProdukt has cell
p1, p2 and p3. TblBestilling has cell b1, b2, b3 and ProduktName.

How can I have two tables held open at the same time and what would the query/VB-script be?

SELECT * from tblProdukt AND tblBestilling WHERE tblBestilling.ProduktName = session("ProduktName"),

AND
tblProdukt.p1 = tblBestilling.b1
AND
is tblProdukt.p2 <> tblBestilling.b2
AND
is tblProdukt.p3 = tblBestilling.b3

Do While ObjRs. not EOF
<%=ProduktName%>
Loop

Do you know how to make a query out of this?

Med vennlig hilsen
grstad

__________________
Internet has become favorable with that tool...thank you Tim Berners-Lee!
 
Old April 1st, 2006, 01:21 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... what I am asking is; how do I find equal records from to different tables...?

 
Old April 3rd, 2006, 12:33 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

SELECT * FROM tblProdukt INNER JOIN tblBestilling ON tblProdukt.p1 = tblBestilling.b1
WHERE tblProdukt.p2 NOT IN (SELECT tblBestilling.b2 FROM tblBestilling) AND tblProdukt.p3 IN (SELECT tblBestilling.b3 FROM tblBestilling)

If this errors out, post the error.


Thanks,
Richard


 
Old April 4th, 2006, 01:10 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... thank you. I will try it as soon as I can and let you know how it turns out...

 
Old April 5th, 2006, 01:17 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

... it is a rather long query with lines filling the hole screenwidth. Does that matter? Is it a legal way to split up the linelenght? Does it have anything to do with "expected end"?

This is the error;

Feiltype:
Microsoft VBScript-kompileringsfeil (0x800A0401)
Forventet slutt på setning
/innsjekk/trefflisteyngre.asp, line 76, column 107
objCommand.CommandText = "SELECT * FROM Bestilling INNER JOIN Produkt ON Bestilling.ProduktNavn = Session("navn")" & "WHERE Bestilling.PartnerFodt < (SELECT Produkt.ProduktFodt FROM Produkt)"
.
.
.
... & "OR Bestilling.PartnerTelemark IN (SELECT P '<-- line 76


Med vennlig hilsen


 
Old April 5th, 2006, 02:20 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

It doesn't matter how long it is.

Do this:

After your loop builds the query, type:

Response.Write objCommand.CommandText
Response.End

That way we can see the query without throwing an error. If you get an error before doing this then we know something else is wrong in your code before you even get to there.

Also, please try making your query in either SQL designer where you can add the tables and graphically create the joins, add tables etc. or use Query Analyzer. Then you can come up with a query that gets the result set you need. Then it will be easy to figure out in the code how to make this query dynamic. Its just totally guessing right now. We need to find a good query first before proceeding.

Thanks,
Richard

 
Old April 6th, 2006, 06:24 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...can I not just cut the query out, and then see if the code errors..? Or do you meen that the query itself together with the rest of the code maight give an error..? Hmmmmm

Did you meen just to move the query til after the Do Until, and replace the <%= %> with your <%= %>?



 
Old April 12th, 2006, 07:31 AM
Friend of Wrox
 
Join Date: May 2005
Posts: 189
Thanks: 0
Thanked 0 Times in 0 Posts
Default

..yes, I will try what you said, but until then I get this error;
"expected end"

Microsoft VBScript-kompileringsfeil (0x800A0401)
Forventet slutt på setning
/innsjekk/trefflisteI.asp, line 244, column 105
objCommand.CommandText = "SELECT * FROM Produkt INNER JOIN Bestilling ON Produkt.ProduktNavn <> session("navn")"
--------------------------------------------------------------------------------------------------------^



Set objCommand = Server.createObject ("ADODB.Command")

objCommand.ActiveConnection = kobling

objCommand.CommandText = "SELECT * FROM Produkt INNER JOIN Bestilling ON Produkt.ProduktNavn <> session("navn")"
WHERE Produkt.produktSnekker IN (SELECT Bestilling.PartnerSnekker FROM Bestilling) AND Produkt.ProduktMale IN (SELECT Bestilling.PartnerMale FROM Bestilling)"


objCommand.CommandType = adCmdText

set ObjRs1 = objCommand.Execute
Set objCommand = Nothing

While not ObjRs1.EOF
    response.Write ObjRs1("ProduktNavn") & "<br>"
    ObjRs1.MoveNext
Wend
ObjRs1.Close
Set ObjRs1 = Nothing








Similar Threads
Thread Thread Starter Forum Replies Last Post
join dhara_adh SQL Server 2000 2 January 2nd, 2007 12:39 AM
Join or not join madhukp SQL Server 2000 3 February 2nd, 2005 01:11 AM
More than one join jaywhy13 Classic ASP Basics 2 January 31st, 2005 11:38 PM
INNER JOIN msmagied Classic ASP Databases 3 August 29th, 2004 12:28 PM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM





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