我無法解決這個問題很多小時。
這是我的表如何將結果與條件分組?
t1:
–––––––––––––––––––––––––––––––––––
| id | text | lang | transl_id |
–––––––––––––––––––––––––––––––––––
| 1 | first | en | 222 |
–––––––––––––––––––––––––––––––––––
| 2 | second | de | 222 |
–––––––––––––––––––––––––––––––––––
| 3 | jkj | de | 234 |
–––––––––––––––––––––––––––––––––––
| 4 | 89080 | de | 235 |
–––––––––––––––––––––––––––––––––––
這裏是我的查詢:
SELECT
transl_id AS property,
(SELECT text FROM t1 WHERE lang='en') AS value1,
(SELECT text FROM t1 WHERE lang='de') AS value2,
FROM t1
它返回如下表:
–––––––––––––––––––––––––––––––––––
| property | value1 | value2 |
–––––––––––––––––––––––––––––––––––
| 222 | first | |
–––––––––––––––––––––––––––––––––––
| 222 | | second |
–––––––––––––––––––––––––––––––––––
| 234 | jkj | |
–––––––––––––––––––––––––––––––––––
| 235 | 89080 | |
–––––––––––––––––––––––––––––––––––
每行有兩種value1
或value2
,不可能兼顧。有沒有辦法對結果進行分組,以便property
字段的值相等的行將在一行中?我的意思是這樣的:
–––––––––––––––––––––––––––––––––––
| property | value1 | value2 |
–––––––––––––––––––––––––––––––––––
| 222 | first | second |
–––––––––––––––––––––––––––––––––––
...
'...按屬性值,值1,值2'? –
@MarcB:仔細看看這個問題,我不認爲就是這樣。標題具有誤導性。如我錯了請糾正我。 –
對不起,我不明白。請稍等,我會更新問題並添加詳細信息。 –