我遇到一个从2个表中获取数据的查询有问题:
SELECT C.*, US.*
FROM `".DB_TABLE_USERS."` US
LEFT JOIN ".DB_TABLE_AUTH." AS AU ON AU.auth_user_id=US.".DB_TABLE_USERS_ROW_ID."
LEFT JOIN ".DB_TABLE_CLINICS." C ON C.".DB_TABLE_CLINIC_ROW_ID." = US.".DB_TABLE_USERS_ROW_CLINIC."
WHERE AU.auth_code_id = '".$_SESSION[ AUTH_SESSION_AUTHID ]."'
结果是这样的(我已经从这里删除了一些字段):
Array
(
[clinic_id] => 1
[clinic_row1] => Row1
[clinic_row2] => Row2
[user_id] => 8
[user_username] => owner
)
但我想这样......:
Array
(
[user_id] => 8
[user_username] => owner
[clinic_data] => Array (
[clinic_id] => 1
[clinic_row1] => Row1
[clinic_row2] => Row2
)
)
有可能吗?我试过了
C.* AS clinic_data
但这不起作用。 任何人都可以帮忙吗?