CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 comparing two fields in different tables in WHERE clause

Print topic Send  topic

Author Message
Chris__T


Posts: 339
Posted: 10/03/2007, 12:05 PM

Is there a way to do the following select (like in Dlookup?)

SELECT Permit_No FROM Table1 WHERE Table1.Address like Table2.Address

I want to get Permit_No from table1, but its WHERE condition depends on comparing two address fields in different tables. Will that work?
View profile  Send private message
Bubba

Posts: 33
Posted: 10/18/2007, 6:01 PM

This is not exact coding, but should give you a rough idea of how you could do it.

Dim Address2

Address2 = CCDLookUp("Address","[ Table2]" DBConnection1)


Permit_No = CCDLookUp("Permit_No","[ Table1]"," Table1.Address = " & Address2 , DBConnection1)
View profile  Send private message
Chris__T


Posts: 339
Posted: 10/19/2007, 9:08 AM

Ah, that looks very logical. I'll have to give it a try. Thanks!
View profile  Send private message
fabio

Posts: 19
Posted: 10/23/2007, 7:46 PM

you could solve it using an SQL query like this


select
Permit_No
from
table1 t1 inner join
table2 t2 on ( t1.address = t2.address )

Let me see if I understood. If you want to get the Permit_no from table1 only when there's a record with the same addres on Table2, the query above will do it.
View profile  Send private message
fabio

Posts: 19
Posted: 10/23/2007, 7:49 PM

or you could use the following query in CCDLookup

CCDLookup("Permit_no","table1 t1 left join table2 t2 on (t1.address = t2.address)","t2.address is not null", dbConnection)
View profile  Send private message
Chris__T


Posts: 339
Posted: 10/24/2007, 8:40 AM

Quote fabio:
you could solve it using an SQL query like this


select
Permit_No
from
table1 t1 inner join
table2 t2 on ( t1.address = t2.address )

Let me see if I understood. If you want to get the Permit_no from table1 only when there's a record with the same addres on Table2, the query above will do it.



Yes, that is what I'm trying to do. If the address in table2 matches the addresss in table 1, then give me the Permit Number from table1 so I can stick it in table2.

I'll try to look into that when I get a chance...Thanks fabio.
View profile  Send private message
wkempees
Posted: 10/29/2007, 9:40 AM

  
 BusinessLicense.BUS.Value = CCDLookUp('Permit_No','Permit t1 left join  
 BusinessLicense t2 on (t1.Job_Site = t2.CC_address)','t2.address is not  
 null',$DBConnect)  

- use of single qoutes
- $DBConnect not DBConnect

Walter


Chris__T


Posts: 339
Posted: 10/29/2007, 10:13 AM

I'm getting an error with the CCDlookup.

BusinessLicense.BUS.Value = CCDLookUp(Permit_No,Permit t1 left join BusinessLicense t2 on (t1.Job_Site = t2.CC_address),"t2.address is not null",DBConnect)

gives me:

Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/BusinessLicense/NewPage2_events.asp, line 58, column 55

Column 55 would be the space between Permit and t1

Is it giving me an error because one of my tables is named BusinessLicense and the grid is named BusinessLicense?
View profile  Send private message
Chris__T


Posts: 339
Posted: 10/29/2007, 11:21 AM

I tried the single quotes and $dbconnect but still got:

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/BusinessLicense/NewPage2_events.asp, line 58, column 38

BusinessLicense.BUS.Value = CCDLookUp('Permit_No','Permit t1 left join BusinessLicense t2 on (t1.Job_Site = t2.CC_address)','t2.address is not null',$DBConnect)

In the code section it shows everything in the ( ) as comments (in green)
View profile  Send private message
wkempees
Posted: 10/30/2007, 1:27 AM

Then I am lost too, but for being extra friendly to MS VB by doing :

BusinessLicense.BUS.Value = CCDLookUp('Permit_No','Permit as t1 left join
BusinessLicense as t2 on (t1.Job_Site = t2.CC_address)','t2.address is not
null',$DBConnect)

- not the addition of the word 'as'.
And asking you to thoroughly check the spelling and Caps of all fields.
I f.i. notice CC_address, t2.address, Job_Site, as being all different in
camelrules

Walter


"Chris__T" <Chris__T@forum.codecharge> schreef in bericht
news:64726248de9e14@news.codecharge.com...
>I tried the single quotes and $dbconnect but still got:
>
> Error Type:
> Microsoft VBScript compilation (0x800A03EA)
> Syntax error
> /BusinessLicense/NewPage2_events.asp, line 58, column 38
>
> BusinessLicense.BUS.Value = CCDLookUp('Permit_No','Permit t1 left join
> BusinessLicense t2 on (t1.Job_Site = t2.CC_address)','t2.address is not
> null',$DBConnect)
>
> In the code section it shows everything in the ( ) as comments (in green)
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.