SQL – Joining two tables without related data – joining without an on clause

I’m loading test data, and have a situation where I have a list of ID’s I need to generate test-data for, and a list of sample data I’d like to populate for each test ID.  Something like this:



What I want is a join that produces:

1 A
1 B
2 A
2 B
3 A
3 B

This is essentially a join without an “on” clause, however the trick in SQL is that the “join” keyword isn’t needed either.  The select statement is simply:

select * from TestIDs, TestData

Notice that there is a comma seperating the tables to select from, and no join keyword anywhere.  Handy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: