I have 3 columns questionid, replyidand userid.
I want to select everything questionid from userid where userid is session[userid], and then select from it questionid.
Right now, I take all those questionidbelonging $_SESSION['user_id']to the array (and delete duplicates from it), and then I pass another request again
foreach($array as $x)
{
$query="select questionid,replyid,userid from table where questionid=$x"
}
But I think the above steps can be performed in the request itself ( and the above step also does not work ). I tried below but did not work. If I try to pass this request, then a duplicate value will be added:
SELECT distinct(questionid),replyid,userid
from table
where userid=$_SESSION['user_id']
So what should be the request?
questionid,replyid,userid
8 ,2 ,45
8 ,3 ,45
9 ,8 ,41
8,2 8,3 - ( ), ...
, , questionid, * from table where questionid .
, ,
SELECT distinct questionid, `answerid`, `userid`
FROM `table`
WHERE userid='$user'
. limit 0,1
SELECT distinct questionid, `answerid`, `userid`
FROM `table`
WHERE userid='$user'
LIMIT 0,1