我做了一个查询,我用它创建了一个变量accountid,我不能在我的子查询中重用accountid为什么?
这是我的密码:
SELECT userId AS accountId,
(SELECT recommended FROM ads_connections WHERE byUserId = accountId AND throughUserId = accountId AND adId = :recommendedAdId) AS recommended,
--
(SELECT requestStatus FROM ads_recommends_requests WHERE
userId = :currentUserId AND
requestFromUserId = accountId AND
advertisementId = :statusAdId) AS requestStatus,
(SELECT COUNT(id) FROM ads_recommends_requests
WHERE
requestFromUserId = accountId AND
advertisementId = :countAdId AND
requestStatus = '1'
) AS recommendedTimes
--
FROM user_contacts
WHERE userId IN " . $myCircleString . "
AND phoneNumber = :phoneNumber
AND (SELECT fictive FROM users WHERE id = userId) = 0
";
输出示例:
"data": [
{
"userId": 0,
"accountId": 2,
"fictive": false,
"name": "Mickael",
"phoneNumber": "0584688888",
"review": "0",
"liked": false,
"recommended": 0,
"requestStatus": 0,
"recommendedTimes": 0
}
谢谢
2条答案
按热度按时间5ktev3wc1#
看看这个-
n53p2ov02#
应答
按以下方式创建变量:
并使用它: