如何确定这个值2,4,8中的一个是否在(select accessID)中

时间:2014-03-03 18:16:18

标签: php mysql sql

我有三张桌子

usersinformation

userID    surname

---------   ----------

0001      |   Gideon

0002      |   mesaih

0003      |    Princess

发布表

userID    postingID   posting     status

---------   ----------  ---------- ----------
0001      |   1  |  xxxxy          1,2

0002      |   2  |   yyyyyy        3,6

0003      |   3  |   zzzzzzz        1,6

跟随表格

userID   followerID   accessID     
---------   ----------  ---------- 
0002      |   0001  |    1         
0001      |   0002  |    3       
0003      |   0001  |     6     

注意

当用户发帖时,我可以选择那些可以访问(查看)帖子的人 我将accessID存储为以逗号分隔的字符串 例如 3,5,4

请注意 3,5,4 表示某些

3表示朋友

5卑鄙的家庭等等

在帖子可以显示之前,它必须检查想要查看帖子的用户是否已在发布状态中添加了一个accessID,如果是,则会显示

以下所有代码 请帮忙

SELECT 
pt.content,
pt.date, 
pt.postingID, 
pt.dimg,
ui.surname,
ui.lastname, 
ui.userID 

FROM posting as pt

INNER JOIN usersinformation as ui
ON pt.userID = ui.userID 

WHERE pt.userID = '$f_ID' 
OR 
    pt.userID   IN (SELECT follows.userID  FROM follows 
WHERE follows.followerID = '$f_ID')
AND pt.status IN (SELECT follows.accessID 
FROM follows WHERE follows.followerID =    

pt.userID AND follows.userID = '$f_ID')

ORDER BY  pt.postingID DESC



 if user that post has add the viewer with one of the acessID in posting status

感谢您的帮助

0 个答案:

没有答案