我正在学习 MYsql 和 php。现在在 mysql 中遇到了这个奇怪的问题。我有两张 table
soc_users_interest
和 soc_status
。请参见下面的表结构。
---------- -----------
soc_status soc_users_interest
---------- ------------
status_ID soc_interest_id (Auto increment)
status userID
userID Interest
我正在尝试列出与用户(使用该应用程序的用户)具有相同兴趣的用户的所有状态。我进行了查询,但没有返回正确的结果。这是我写的查询,它不起作用。
SELECT soc_status.statusID, soc_status.status FROM soc_status
WHERE soc_status.userID =
(SELECT
soc_users_interest.userID as firstUser ,
soc_users_interest.interest as firstUserInterest ,
secondUser.userID as secondUser,
secondUser.interest as secondUserInterest
FROM soc_users_interest JOIN
soc_users_interest secondUser
ON soc_users_interest.interest = soc_users_interest.interest) WHERE soc_users_interests.userID = "23445";
I am getting this error -> `[2016-07-09 20:53:26] [21000][1241] Operand should contain 1 column(s)`
如何列出与用户(使用该应用程序的用户)具有相同兴趣的用户的所有状态?这个问题有什么解决办法吗?感谢您的帮助;)
最佳答案
SELECT soc2.userID, soc2.status, int.interest FROM soc_status soc1
join soc_status soc2 on soc1.user_id=soc2.user_id and soc1.user_id="23445"
join soc_users_interest int on soc1.user_id=int.user_id
关于php - 如何检索同兴趣用户的状态 Mysql查询问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38287578/