Reputation: 16469
I know I can do:
SELECT COUNT(*) FROM table_a INNER JOIN table_b ON (table_a.attribute = table_b.attribute)
To do an inner join based on the same attributes in table_a
and table_b
.
But what if I have over 100 attributes and I want to do an inner join only when all the attributes are the same. Is there an easier way than to list on all 100+?
Upvotes: 0
Views: 50
Reputation: 11
What about this?
SELECT COUNT(*) FROM table_a INNER JOIN table_b ON
(table_a.attribute1 = table_b.attribute1 and
table_a.attribute2 = table_b.attribute2 and
table_a.attribute3 = table_b.attribute3 ... and
table_a.attribute100 = table_b.attribute100)
Use Aginity+Excel to create the join faster :)
Upvotes: 1
Reputation: 41
If the attributes are the same you can use NATURAL JOIN. It's not one I've actually used but it should do exactly What you want. E.g http://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljnaturaljoin.html.
Upvotes: 0