Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084256
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:24:59+00:00 2026-05-20T18:24:59+00:00

Also, if this isn’t the right place then i’ll move it to stack overflow.

  • 0

Also, if this isn’t the right place then i’ll move it to stack overflow. I posted it here, since when i had a question about mysql over there, they said that this is where such questions should be asked.

The problem that i’m having is with my chat system. I have a normal chat table and then i also have on that is used for private messages. As such the private message chat table only contains the message id that was private, and also the person who was supposed to receive it.

the table schema is something like this.

chat(
id int unsigned not null,
sayer_id int unsigned not null,
message_type tinyint unsigned not null,
message varchar(150) not null,
timesent timestamp on update current_timestamp,
);

the indexes are on id, and timesent. Primary is id, and also a normal index on timesent.
The second table is just.

chat_private(
message_id int unsigned not null,
target_id int unsigned not null
)

the primary is on message id and is also a foreign key. target id currently doesn’t have one at the moment but i may put a normal index on it.

Now then, the query that i’m attempting to do is something like SELECT message, timesent FROM chat WHERE timesent>=last_update AND target_id=$userid;
last_update is a session variable stating when the last time that updates were performed.
$userid is the id from the session variable on the serverside.
Also I don’t know how to easily, do something similar to that since i want to have the join in it from the chat_private table but i also don’t want to have to deal with all of the ids from it since it only holds the target_id/message_id and thus would be rather pointless.

What’s the easiest way to work with the data as it is? If it’s impossible to work with, then i’ll just move the private chat and other subsequent ones into their own table and adjust the data sizes accordingly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:25:00+00:00Added an answer on May 20, 2026 at 6:25 pm

    You want something like

    SELECT chat.message, chat.timesent FROM chat LEFT JOIN chat_private ON chat.id=chat_private.message_id WHERE chat.timesent>='$timestamp' AND chat_private.target_id=$target_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I come from a C and C++ background but also play with some web
I have an executable that is started by a windows service, this program will
Here's an interesting problem that I have just come across. It is possible to
The examples here show a very simplified version of a VIEW that I am
Is there any way to use AppleScript (or something else) to query currently running
I have the following problem: in a database table are Sales recorded. One of
Often times I have elements hooked to added functionality, like: $('.myfav').autocomplete(); $('.myfav').datepicker(); $('.myfav').click(somefunction); But
I want to write a method that uses Reflection to tell whether a given
Below is a function I found about a year ago that is supposed to
I am sorry for possible misleading about the title, but I have no idea

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.