Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

JOIN on two fields Expand / Collapse
Author
Message
Posted Tuesday, June 30, 2009 10:16 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 9, 2010 7:58 PM
Points: 121, Visits: 195
I inherited a weird setup. A Progress database is copied to a SQL Server 2005 database. One of the queries I have been asked to write would be easy if the JOIN that I have to do were on one field. However, this thing is set up very weird. There is nothing unique about any one field in row in Table A or Table B. However, the combination of TableA.Field1 and TableA.Field2 is unique. The same two fields exist in TableB.

If I had free reign on this thing, I would simply add a column and make it a primary key. But I can't. So how can I perform a JOIN in a SELECT statement and the JOIN be based on the fact that both Field1 and Field2 must match in both table for the row to be joined?
Post #744609
Posted Tuesday, June 30, 2009 10:21 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:21 AM
Points: 20,801, Visits: 32,723
select
*
from
TableA ta
inner join TableB tb
on (ta.Col1 = tb.Col1
and ta.Col2 = tb.Col2)


hth



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #744619
Posted Tuesday, June 30, 2009 11:50 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 9, 2010 7:58 PM
Points: 121, Visits: 195
It works for SQL Server, but sadly, not for Progress. I will keep digging. Thanks.
Post #744720
Posted Tuesday, June 30, 2009 12:11 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, November 14, 2014 12:37 PM
Points: 2,361, Visits: 6,752
In oracle this used to work (If my memory serves me right)..

Select * from tablea where (col1,col2) in (Select col1,col2 from tableb)

You could try that


-Roy
Post #744739
Posted Tuesday, June 30, 2009 12:18 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Friday, November 30, 2012 10:04 AM
Points: 73, Visits: 2,131
I don't work with Progress often, but had bookmarked this link to a Progress coding manual when I had a question one time. If you search for 'join' it will take you to examples that may help:

http://www.fast4gl.com/downloads/standard.html
Post #744751
Posted Tuesday, June 30, 2009 12:24 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 4:21 AM
Points: 20,801, Visits: 32,723
Sorry, you said the data was copied to SQL Server from a Progress database, not that you were directly querying a Progress database.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #744757
Posted Tuesday, June 30, 2009 1:03 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, September 9, 2010 7:58 PM
Points: 121, Visits: 195
Yeah, looking back, I was clear as mud. My apologies. I have this query working fine when selecting from SQL Server. However, the MSS data isn't current. I can make it current with a SP that I built. But we wanted to get the same data from the original source, which is Progress, since it's live data. Thing is, the SQL syntax is very weird for Progress, at least from the standpoint of someone who is used to MSS.
Post #744788
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse