0

2 つのテーブルがあり、各テーブルには 3 つの列があります。各テーブルの 1 つの列が次々に追加されるような 1 つの列を取得したい

 eg:- suppose one column in a table contains  hai, how, are, you.
 and another column in another column contains i, am, fine.
 i want a query which gives hai, how, are, you,i,am,fine. in just one column

誰でもこれをSQLでクエリできますか...

4

2 に答える 2

2

あなたの質問はあまり明確ではありません。その解釈の1つは、2つを統合したいということです。

select column
from table1
union
select column
from table2;

両方のテーブルのすべての行(個別の値ではない)が本当に必要な場合、UNIONALLはUNIONよりも高速になります。

行を特定の順序にする場合は、必ずORDERBY句を指定してください。

于 2012-11-06T09:54:08.277 に答える
2

あなたのスキーマを正しく理解していれば、これがあります

Table1:  Column1
          hai,
          how,
          are,
          you.

Table2: Column2
          i,
          am,
          fine.

これを行う:

Insert Into Table1 (Column1)
Select Column2 From Table2

あなたはこれを得るでしょう:

Table1: Column1
         hai,
        how,
        are,
        you.
         i,
        am,
        fine.

3 つの列がある場合は、次のようにします。

Insert Into Table1 (Column1, Column2, Column3)     //the (Column1, Column2, Column3) is not neccessary if those are the only columns in your Table1
Select Column1, Column2, Column3 From Table2       //the Select Column1, Column2, Column3 could become Select * if those are the only columns of your Table2

編集:テーブルを変更したくない場合は、これを行ってください。

Select Column1, Column2, Column3
From Table1
UNION ALL
Select Column1, Column2, Column3
From Table2
于 2012-11-06T09:50:31.730 に答える