2011-07-26 6 views
0

私はこれに新しいので、説明と私と一緒に裸をしてください。異なるテーブルを連結しますか?

2つの異なるテーブルから連結する必要があります。

s.panelid(結果は "AA"と同じ)をb.modulecodesと返し、number_of_stringsを返します。 s.panelid(結果は「AA」など)とnumber_of_stringを入れてください。

select concat(Mid(s.panelid, 5, 2), ' - ' , '??') as `Module Type-Strings` 
from r2rtool.stringtopanel s, be.modulecodes b 
where s.insertts > '2011-07-15' and s.insertts < '2011-07-26' and Mid(s.panelid, 5, 2) != 99 
group by date(insertts), `Module Type-Strings` 
order by `Module Type-Strings`; 

Be(表):modulecodes、number_of_strings

  • AA - 12
  • AB - 4
  • AD - 3
  • AE - 12

I上記のクエリを実行すると、次のような結果が返されます。Module Type-Strings = 'AA- ??' 「AB- ??」もちろん。

私が探しています

Module Type-Strings = 'AA-12'

答えて

0

をちょうどあなたはすでにそれを試していない場合には...

は、あなたがこれを試したことがありますか?

select concat(Mid(s.panelid, 5, 2), ' - ' , b.number_of_string) as `Module Type-Strings` 
from r2rtool.stringtopanel s, be.modulecodes b 
where s.insertts > '2011-07-15' and s.insertts < '2011-07-26' and Mid(s.panelid, 5, 2) != 99 
group by date(insertts), `Module Type-Strings` 
order by `Module Type-Strings`; 

私は基本的に '??'あなたが求めている列、be.modulecodesテーブルのnumber_of_string(from句のbのエイリアス)。

+0

s.panelid - > b.modulecodesに基づいてb.number_of_stringsを取得する必要があります。 – TheRealDK

関連する問題