Jump to content

Recommended Posts

I tried to join same table (with aliases) but cant make to work.

 

Here is code (separate):

SELECT * FROM ".$table_prefix."online_users ORDER BY user ASC

and

SELECT session FROM ".$table_prefix."online_users WHERE session='".$session."'

and

SELECT user_name,user_id FROM ".$table_prefix."users ORDER BY user_date DESC LIMIT 1

 

How to do this in one single query? (is it possible?)

Link to comment
https://forums.phpfreaks.com/topic/208880-join-same-table/
Share on other sites

Oh...you didnt understand :D .

 

This is SELECT with different conditions (WHERE and LIMIT).

In first I need to select all to get all users online.

Second query check if user session exists (if not its INSERT another 'session' +1 user online).

And third query checks last registered user from different table ('users' not 'user_online'). But this can be separated query. I want at least to "wrap" first 2 queries in one.

 

---

Sorry I wrote wrong title of this topic - "Join same table".

Link to comment
https://forums.phpfreaks.com/topic/208880-join-same-table/#findComment-1091081
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.