Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile SQL Reference Table query

Status
Not open for further replies.

rgh3320

Programmer
Sep 11, 2012
2
GB
I am completely new to SQL server i know a few of the basics. I have a VS2010 asp.net c# application with two dropdown listboxes and a textbox. I need to calculate the numbers e.g 3 + 3 = Medium, using the table below to calculate the answer so i can insert the output value into a textbox. Could anyone please help ?

Regards Rob


Table
1 2 3 4 5
1 Cold Cold Cold Cold HOT
2 Cold Cold Cold Medium HOT
3 Cold Medium Medium HOT HOT
4 Medium Medium Medium HOT HOT
5 Medium Medium Medium HOT HOT
Drop down Listbox 3 Drop down Listbox 3

TextBox Medium
 
I would put this information in a table that has 3 columns. Something like this...

[tt]
FirstNumber SecondNumber Temperature
----------- ------------ -----------
1 1 Cold
1 2 Cold
1 3 Cold
1 4 Cold
1 5 Hot
2 1 Cold
2 2 Cold
2 3 Cold
2 4 Medium
2 5 Hot
3 1 Cold
3 2 Medium
3 3 Medium
3 4 Hot
3 5 Hot

Etc....

[/tt]

Then it becomes a simple lookup, like this...

Code:
Select Temperature
From   YourTableName
Where  FirstNumber = 3
       And SecondNumber = 3



-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top