Click here to Skip to main content
15,921,203 members
Home / Discussions / Database
   

Database

 
AnswerRe: Dynamic SQL and the Crystal Report Pin
Mycroft Holmes3-Jul-10 20:38
professionalMycroft Holmes3-Jul-10 20:38 
QuestionI want to know that which is better to save a graph either XAML or SQL databse. Pin
hotthoughtguy2-Jul-10 20:59
hotthoughtguy2-Jul-10 20:59 
AnswerRe: I want to know that which is better to save a graph either XAML or SQL databse. Pin
Mycroft Holmes2-Jul-10 22:39
professionalMycroft Holmes2-Jul-10 22:39 
QuestionComplicated size calculation Pin
Member 34269362-Jul-10 5:35
Member 34269362-Jul-10 5:35 
AnswerRe: Complicated size calculation Pin
Mycroft Holmes2-Jul-10 11:43
professionalMycroft Holmes2-Jul-10 11:43 
QuestionHello Pin
gertag2-Jul-10 1:08
gertag2-Jul-10 1:08 
AnswerRe: Hello Pin
Mycroft Holmes2-Jul-10 1:53
professionalMycroft Holmes2-Jul-10 1:53 
QuestionJoining columns from two tables into one column Pin
RossouwDB1-Jul-10 22:05
RossouwDB1-Jul-10 22:05 
Good Day,

I wonder if it is possible to joins two columns from two tables (ie column 1 from table A and column 2 from table B) into one column.

Here are my tables (note that the columns from both the tables have the same names)

TableA
----------------------
|Column1  | Column2  |
----------------------
| aaaa    |  12345   |
----------------------
| bbbp    |  12245   |
----------------------
| ccc     |  12245   |
----------------------


TableB
----------------------
|Column1  | Column2  |
----------------------
| asd     |  12245   |
----------------------
| bbb     |  12245   |
----------------------
| ddd     |  12245   |
----------------------


The first part of my SQL statement combines the two columns of each table into one column in each table, thus
TableA
------------------
|Column3         |
------------------
| aaa : 12345    |
------------------
| bbbp : 12245   |
------------------
| ccc : 12245    |
------------------


TableB
------------------
|Column4         |
------------------
| asd : 12245    |
------------------
| bbb : 12245    |
------------------
| ddd : 12245    |
------------------


Now, what I want to do is to combine these two columns into one column.

The SQL statement below gives me the following result
Result Sigh | :sigh:
------------------------------
| Column 1     | Column2     |
------------------------------
| bbbp : 12245 | asd : 12245 |
------------------------------
| bbbp : 12245 | bbb : 12245 |
------------------------------
| bbbp : 12245 | ddd : 12245 |
------------------------------
| ccc: 12245   | asd : 12245 |
------------------------------
| ccc: 12245   | bbb : 12245 |
------------------------------ 
| ccc: 12245   | ddd : 12245 |
------------------------------


What I want is this : Confused | :confused:
----------------
| Column1      |
----------------
| bbbp : 12245 | 
----------------
| ccc: 12245   |
---------------- 
| asd : 12245  |
---------------- 
| bbb : 12245  |
---------------- 
| ddd : 12245  |
----------------


Here is my SQL statement
SELECT TableA.Column1 + ' : ' + TableA.Column1 AS Column3, TableB.Column1 + ' : ' + TableB.Column2 AS Column4
FROM TableA FULL OUTER JOIN
     TableB ON TableA.Column1 = TableB.Column1
WHERE (TableA.Column1 IN
       (SELECT Column1
        FROM TableA
        WHERE (Column2 = '12245'))) AND (TableB.Column1 IN
                                         (SELECT Column1
                                          FROM TableB
                                          WHERE (Column2 = '12245')))


I've tried all kinds of joins; left outer, right outer, inner, cross. All with the same results.

I would really appreciate your help, as this is kinda urgent!Cool | :cool:

Thanx a lot!
Rossouw
Big Grin | :-D

P.S I am using SQL Server 2005
AnswerRe: Joining columns from two tables into one column Pin
David Skelly1-Jul-10 22:32
David Skelly1-Jul-10 22:32 
AnswerRe: Joining columns from two tables into one column Pin
Mycroft Holmes1-Jul-10 22:43
professionalMycroft Holmes1-Jul-10 22:43 
GeneralRe: Joining columns from two tables into one column Pin
RossouwDB1-Jul-10 22:54
RossouwDB1-Jul-10 22:54 
GeneralRe: Joining columns from two tables into one column Pin
Mycroft Holmes1-Jul-10 23:19
professionalMycroft Holmes1-Jul-10 23:19 
GeneralRe: Joining columns from two tables into one column Pin
Jörgen Andersson1-Jul-10 23:00
professionalJörgen Andersson1-Jul-10 23:00 
GeneralRe: Joining columns from two tables into one column Pin
Mycroft Holmes1-Jul-10 23:15
professionalMycroft Holmes1-Jul-10 23:15 
Questionreplace the value with different text in Select Pin
indian14330-Jun-10 15:30
indian14330-Jun-10 15:30 
AnswerRe: replace the value with different text in Select Pin
Mycroft Holmes30-Jun-10 17:37
professionalMycroft Holmes30-Jun-10 17:37 
GeneralRe: replace the value with different text in Select Pin
CitrusTech30-Jun-10 19:41
CitrusTech30-Jun-10 19:41 
GeneralRe: replace the value with different text in Select Pin
indian14330-Jun-10 19:41
indian14330-Jun-10 19:41 
QuestionGet child table rows in parent column using sql server 2005 Pin
alisolution30-Jun-10 8:44
alisolution30-Jun-10 8:44 
AnswerRe: Get child table rows in parent column Pin
Jörgen Andersson30-Jun-10 9:54
professionalJörgen Andersson30-Jun-10 9:54 
AnswerRe: Get child table rows in parent column using sql server 2005 Pin
i.j.russell30-Jun-10 10:52
i.j.russell30-Jun-10 10:52 
QuestionFOR XML Path is giving error [modified] Pin
indian14329-Jun-10 13:55
indian14329-Jun-10 13:55 
AnswerRe: FOR XML Path is giving error Pin
Md. Marufuzzaman29-Jun-10 20:15
professionalMd. Marufuzzaman29-Jun-10 20:15 
QuestionRe: FOR XML Path is giving error Pin
i.j.russell29-Jun-10 23:06
i.j.russell29-Jun-10 23:06 
AnswerRe: FOR XML Path is giving error Pin
indian14330-Jun-10 7:34
indian14330-Jun-10 7:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.