SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Combinations
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

bobinorlando
Starting Member

1 Posts

Posted - 09/06/2013 :  18:55:07  Show Profile  Reply with Quote
How would I write a query to produce all combinations for a situation such as the following?

Suppose I wanted to write a sentence, "This is [adjective] [noun]." where [adjective] comes from the Adjective table and [noun] come from the Noun table.

Adjective table looks like e.g.

ID Adj
1 good
2 so so
3 bad

Noun table looks like e.g.

ID Noun
1 apple
2 orange
3 banana

And the result set would look like

This is good apple.
This is so so apple.
This is bad apple.
This is good orange.
This is so so orange.
This is bad orange.
This is good banana.
This is so so banana.
This is bad banana.

I would take a stab at this myself and post even something that doesn't work, but I honestly have no idea how to approach it.

Any pointers in the right direction would be appreciated.

Thanks in advance.

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 09/06/2013 :  19:49:44  Show Profile  Reply with Quote
select 'This is '+ Adjective.Adj+' '+Noun.Noun
from
Adjective,Noun

should do it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000