Well That was indeed what I was searching for but. If I read it out loud, I think with this query I only check if the current user is still onlien and not his conversation partner. In the chat table is store the session_id's of both the chatters of the conversation. There is no way to tell if $thisuser is the user1_sessionid record or user2_sessionid record. So I check them both. After that I have all results where (user1_sessionid record = $thisuser or user2_sessionid record = $thisuser) I need to get the other field. In the first case the users of which the time needs to be checked is user2_sessionid, in the second case user1_sessionid. So something like: select * from chat c1, chat_online c2 where UNIX_TIMESTAMP(c2.activity)>=$limit_time and c2.session_id = (c2.user1_sessionid if (c1.user1_sessionid = $thisuser)) or (c2.user1_sessionid if(c1.user2_sessionid = $thisuser)); Can I do something like this? >>-----Original Message----- >>From: Ligaya Turmelle [mailto:lig@xxxxxxxx] >>Sent: zondag 28 november 2004 2:25 >>To: rv@xxxxxxxx >>Cc: php-general@xxxxxxxxxxxxx >>Subject: Re: mysql query with exclude >>Sounds like you need a join. Maybe something like: >> >>select * from chat c1, >> chat_online c2 >>where >> UNIX_TIMESTAMP(c2.activity)=$limit_time and >> c2.session_id = $thisuser and >> ((c1.user1_sessionid = $thisuser) or >> c1.user2_sessionid = $thisuser)); >>Respectfully, >>Ligaya Turmelle >>Reinhart Viane wrote: > Hey all, > > Hope you all have fun this saturday evening :) > I'm sure i'm having fun except i'm kinda stuck... > > Ok here goes... > > I have 2 tables, one with the people online (chat_online): session_id > activity > > > And a second one where i keep the conversations between people(chat): > user1_sessionid user2_sessionid > chat_conv > > To see what chatter are still online during the last 2 minutes i do a > check like this on the chat_online table: $limit_time= time()-130; > $sqlchatonline="select * from chat_online where UNIX_TIMESTAMP(activity) > >>=$limit_time"; > > > ok, on my page i also do a query to see what conversations are going > on with the user: $thisuser=session_id(); > $getchatlist="select * from chat where (user1_sessionid=$thisuser) or > (user2_sessionid=$thisuser)"; > > This selects all the conversations which this user has been/or is > into. I list all the chatpartners of thisuser. Off course it is > possible that other chatters who had a conversation with this user are > not online anymore. So i need to combine those two queries in a way... > > this is what i think it should be: > $getchatlist=select * from chat where (user1_sessionid=$thisuser) or > (user2_sessionid=$thisuser); > $resultchatlist=mysql_query($getchatlist); > while ($row=mysql_fetch_array($resultchatlist)) { > get the second chattersessionid in each conversation and check > if this chatter was still online in the last two minutes. > if he is not, exclude him from the array and do not show him > in the list (optional delete the record in the database) } > > or maybe i can combine those two queries in one? > > Can someone help me out on this? > > Thx in advance, > Reinhart > > > > > > _____ > > Reinhart Viane > <mailto:rv@xxxxxxxx> rv@xxxxxxxx > Domos || D-Studio > Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 -- > fax +32 15 43 25 26 > > > STRICTLY PERSONAL AND CONFIDENTIAL > This message may contain confidential and proprietary material for the > sole use of the intended > recipient. Any review or distribution by others is strictly prohibited. > If you are not the intended > recipient please contact the sender and delete all copies. > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php