喜我的問題左連接SQL查詢
contact_message表(1個數據)
-id
-messageid
-message
-date
列表contact_message數據
MySQL的左連接的SQL查詢列表中的解決方案
Array
(
[0] => Array
(
[id] => 5
[messageid] => 1
[message] => A new e-mail
[date] => 2017-01-18
)
)
contact_reply表(2數據)
-id
-messageid
-reply
-date
列表contact_reply數據
Array
(
[0] => Array
(
[id] => 1
[messageid] => 5
[reply] => Thanks I save mail adress
[date] => 2017-01-18
)
[1] => Array
(
[id] => 1
[messageid] => 5
[reply] => Sorry What is your name ?
[date] => 2017-01-18
)
)
SQL查詢
SELECT im.message,im.date,ic.reply,ic.date
from contact_message as im
left join contact_reply as ic
on im.id=ic.messageid
where im.messageid=:siral
結果
Array
(
[0] => Array
(
[message] => A new e-mail
[date] => 2017-01-18
[reply] => Thanks I save mail adress İSMAİL ÇİLOĞLU
)
[1] => Array
(
[message] => A new e-mail
[date] => 2017-01-18
[reply] => Sorry What is your name ?
)
)
正常[1] INDIS消息null值,但寫的[0] INDIS [消息]值
我想結果
Array
(
[0] => Array
(
[message] => A new e-mail
[date] => 2017-01-18
[reply] => Thanks I save mail adress İSMAİL ÇİLOĞLU
)
[1] => Array
(
[message] =>null
[date] => 2017-01-18
[reply] => Sorry What is your name ?
)
)
對不起,但我不確定你在問什麼。 –
joe C. sql查詢結果[1]消息列通常爲空但寫[0] indis mesage列值:( –
對不起,我的中間和不好:/ –