0

私はこの状況にあります:

Table A:
+----+------------+
| id | text       |
+----+------------+
| 33 | str1       | 
| 34 | str2       | 
| 35 | str3       | 
| 36 | str4       | 
+----+------------+

Table B:
+----+--------+------+------------+----------+-------+
| id | title  | teme | year       | ed       | cont |
+----+--------+------+------------+----------+-------+
|  8 |     33 |   34 | 2012-04-06 |       35 |    36 | 
+----+--------+------+------------+----------+-------+

1つのクエリでこの結果が得られる可能性はありますか?:

+----+--------+------+------------+----------+-------+
| id | title  | teme | year       | ed       | cont |
+----+--------+------+------------+----------+-------+
|  8 |   str1 | str2 | 2012-04-06 |     str3 |  str4 | 
+----+--------+------+------------+----------+-------+

テーブルAは、他の2つのテーブル間のJOINの結果です。

私が使用したDBMSはMysqlです

前もって感謝します

4

1 に答える 1

3

私が思いつくことができるのは

select b.id, 
       (select a.text from tableA a where a.id = b.title) as title, 
       (select a.text from tableA a where a.id = b.teme) as teme, 
       year, 
       (select a.text from tableA a where a.id = b.ed) as ed, 
       (select a.text from tableA a where a.id = b.cont) as cont
from tableB b
where b.id = 8
于 2012-04-10T10:41:27.583 に答える