2012-03-06 242 views
-2

海蘭all..I有關於query.I的問題有3個表什麼,我想要做的就是將它們結合起來得到一個漂亮的result.So我有以下3個表:select查詢語句

personal 
- cod_numeric_personal 
- nume 


    Raspunsuri 
- raspuns 
- cod_numeric_personal 
- data_raspuns 
- id_intrebare 

    Intrebari 
-intrebari 
-id_intrebare 

我做了這個查詢:

SELECT personal.nume, Raspunsuri.raspuns, Intrebari.intrebari 
FROM personal 
INNER JOIN Raspunsuri ON personal.cod_numeric_personal = Raspunsuri.cod_numeric_personal 
INNER JOIN Intrebari ON Raspunsuri.id_intrebare = Intrebari.id_intrebare 

這帶來了用戶的姓名,答案以及每個answer.What我想的問題是,彈出的名字只有一次,每個疑問,是「intrebare」是列的名稱和每列的答案。所以像..Intrebare1 ... Answer1 ...但Intrebare1是不適用我的專欄。

回答

0
SELECT personal.nume, Raspunsuri.raspuns, Intrebari.intrebari AS Answer 
FROM personal 
INNER JOIN Raspunsuri ON personal.cod_numeric_personal = Raspunsuri.cod_numeric_personal 
INNER JOIN Intrebari ON Raspunsuri.id_intrebare = Intrebari.id_intrebare 
Group By nume