Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
SQL Server 2005 General Discussion
»
JOIN on two fields
JOIN on two fields
Rate Topic
Display Mode
Topic Options
Author
Message
middletree
middletree
Posted Tuesday, June 30, 2009 10:16 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, September 09, 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
Lynn Pettis
Lynn Pettis
Posted Tuesday, June 30, 2009 10:21 AM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 11:14 PM
Points: 21,832,
Visits: 27,862
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
middletree
middletree
Posted Tuesday, June 30, 2009 11:50 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, September 09, 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
Roy Ernest
Roy Ernest
Posted Tuesday, June 30, 2009 12:11 PM
Hall of Fame
Group: General Forum Members
Last Login: Thursday, June 13, 2013 11:29 AM
Points: 3,280,
Visits: 6,626
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
cindyj
cindyj
Posted Tuesday, June 30, 2009 12:18 PM
Valued 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
Lynn Pettis
Lynn Pettis
Posted Tuesday, June 30, 2009 12:24 PM
SSC-Insane
Group: General Forum Members
Last Login: Yesterday @ 11:14 PM
Points: 21,832,
Visits: 27,862
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
middletree
middletree
Posted Tuesday, June 30, 2009 1:03 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Thursday, September 09, 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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.