Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
namratadas
Starting Member
4 Posts |
Posted - 2011-06-14 : 16:32:04
|
| I have two tables TableA and TableB. In my select Query from TableA i need to retrieve two columns Key(column1) and Value(column2)(ie one key Column1 can have multiple values in Column2) .From the second table i need one value column(Column3). If column2 is string then i change the value in column3 for all the Keys in Columns1 for that specific ID. Can somebody help? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-14 : 16:44:44
|
| You'll have to post the DDL (CREATE TABLE statements), some sample data, and the expected results. Right now your question is too vague. |
 |
|
|
jcelko
Esteemed SQL Purist
547 Posts |
Posted - 2011-06-15 : 13:30:03
|
| People cannot read your mind, so post your code and clear specs if you really want help. Please post real DDL and not narrative or your own personal programming language. Learn to use ISO-11179 rules for the data element names, avoid needless dialect and use ISO-8601 temporal formats, codes and so forth. Please tell us what SQL product and release you are using. Tell us if you can change the DDL or if you are stuck with it. Now to do your job for you and make it into real SQL. >> I have two tables Foobar and Widgets. In my select Query from Foobar I need to retrieve two columns (Colors.color_id, Colors.color_name). > .. one key color_name can have multiple values in Widget.color_nbr. CREATE TABLE Colors(color_nbr INTEGER NOT NULL PRIMARY KEY, color_name CHAR(15) NOT NULL UNIQUE);CREATE TABLE Widgets(widget_id INTEGER NOT NULL PRIMARY KEY, color_nbr CHAR(15) NOT NULL REFERENCES Colors(color_nbr) ON UPDATE CASCADE);>> From the Widgets table I need one value of (Widgets.color_nbr).<<>> If column2 is string .. <<UNH?? You declared this column; you already know if it is a string! >> then I change the value in Widgets.color_nbr for all Colors.color_nbr <<The DRI actions will cascade any chnges in the Colors table to the Widgets without any programming. --CELKO--Books in Celko Series for Morgan-Kaufmann PublishingAnalytics and OLAP in SQLData and Databases: Concepts in Practice Data, Measurements and Standards in SQLSQL for SmartiesSQL Programming Style SQL Puzzles and Answers Thinking in SetsTrees and Hierarchies in SQL |
 |
|
|
namratadas
Starting Member
4 Posts |
Posted - 2011-06-15 : 13:38:18
|
| Sorry about not describing my problem clearly this was my first post. I have resolved my problem. THank you for looking into the issue. |
 |
|
|
|
|
|