假设应该是这样的:
select userViewer.item, items.itemName
from likes userViewer,
likes userProfile,
items
where userProfile.user = $profileUserId
and userViewer.user = $userViewer
and userProfile.item = userViewer.item
and items.item = userViewer.item
其中 $profileUserId - 配置文件用户的 userId 和 $userViewer - 当前用户的 userId
使用“items”表对“join on”表单进行相同的查询,例如:
select userViewer.item, items.itemName
from likes userViewer inner join likes userProfile
on userProfile.user = $profileUserId
and userViewer.user = $userViewer
and userProfile.item = userViewer.item
inner join items
on userViewer.item = items.item