1

mysql には、列数が異なる 15 個のテーブルがあります。列数の範囲は 225 ~ 250 です。毎日 15 の異なる CSV ファイルからデータをインポートしています。

すべてのテーブルには、特定の日の同じ値を持つ 19 の共通列があり、3 つの共通列の組み合わせが主キーとして機能します。

レポートとして表示するには、15 個のテーブルから重複することなくデータを取得する必要があります。これを行う方法?

参照サンプルのテーブル構造は次のとおりです。

<html>
<table cellpadding="0" cellspacing="auto" border="1" class="display" id="example" width="100%">
            <thead>
                <tr>
                        <th>Start time </th>
                        <th>End time </th>
                        <th>Query Granularity</th>
                        <th>RNC ID</th>
                        <th>Cell</th>
                        <th>Cellname</th>
                        <th>Access Success Rate Signalling (%)</th>
                        <th>Access Success Rate Speech (%)</th> 
                        <th>Access Success Rate PS (%)</th>
                        <th>Access Success Rate HS (%)</th>
                        <th>Call Drop Rate Speech (%)</th>
                        <th>Call Drop Rate PS (%)</th>
                        <th>Call Drop Rate HS (%)</th>
                        <th>HOSR Speech (%)</th>
                        <th>iRAT HOSR out Speech (%)</th>
                        <th>iRAT HOSR out PS R99 (%)</th>
                        <th>number of rab establishment success for speech</th> 
                        <th>number of rab establishment success for PS</th>
                        <th>number of rab establishment success for HS  </th>
                        <th>number of CS call drop  </th>


                </tr>
            </thead>

            <tbody>
</table>
</html>
4

1 に答える 1

1

前述のように、UNION クエリを作成するには、共通の列数が必要です。重複を削除するには、UNION ステートメントを SELECT DISTINCT <columna columnb > ステートメントで囲みます。

select distinct columna columnb from    
(   
    select subcol0a columna, subcol0b columnb, '', '' from table0    
        union
    select subcol1a columna, subcol1b columnb, '', '' from table1 
 )  as query0
where <some condition>  

サブクエリの個々の列にエイリアスを付けて、外側の SELECT で収集されたときに一致するようにします。

于 2012-10-22T14:31:29.050 に答える