2
我有這三種不同的queries.These查詢給了我獨立導致correct.now我要合併這三種查詢到單個查詢或視圖來獲取導致一個查詢變得非常容易。轉換嵌套查詢到SQL視圖
$sql1 = "select * from user_post_like
inner join user_post
on user_post_like.postID = user_post.postID
where ((user_post.poster='$uID' AND user_post_like.userID!='$uID' ) OR (user_post.wallID='$uID'
AND user_post_like.userID!='$uID')
AND user_post_like.notificationStatus=0)";
$sql2 = "select * from user_post_comment
inner join user_post
on user_post_comment.postID = user_post.postID
where ((user_post.poster='$uID' AND user_post_comment.commenter!='$uID') OR (user_post.wallID='$uID' AND user_post_comment.commenter!='$uID')
AND user_post_comment.notificationStatus=0)";
$sql3 = "select * from user_post_share
inner join user_post
on user_post_share.postID = user_post.postID
where ((user_post.poster='$uID'
AND user_post_share.Share_user_id!='$uID') OR (user_post.wallID='$uID' AND user_post_share.Share_user_id!='$uID') AND
user_post_share.notificationStatus=0)";
的感謝!我有不同結構的表 – Swapnil
然後使用連接語法。希望你不需要像在例子中那樣使用*,你最好選擇你的程序需要的列。 –