Q

Can SQL combine tables like these? Doubtful

Can SQL combine tables where the values don't relate to one another? One expert says it's difficult unless you redesign the tables.

I have two tables that look like these:

I would like to create a new table that combines these tables and looks like this:

Can SQL combine tables like these? If so, how?

IT Knowledge Exchange author Denny Cherry responds: There is no reliable way of joining these values because they don't relate to each other. You could, I suppose, join them based on row numbers, but if the rows change order, the joined rows would be different, so that would be very unreliable. The tables need to be redesigned with some sort of relationship between the values.

This was first published in December 2013

Dig deeper on SQL-Transact SQL (T-SQL)

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

1 comment

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close