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 6534449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:15:08+00:00 2026-05-25T10:15:08+00:00

I have three tables set up in a MySQL database called event, status and

  • 0

I have three tables set up in a MySQL database called “event”, “status” and “user”. (as shown below:

EVENT TABLE (below)
Event Table

STATUS TABLE (below)
Status Table

USER TABLE (below)
User Table

and when I get data from the event table I use the SQL query statement below to bind the persons first and last names together as one variable called “name” and then bind that name to the respective user_id; and so on. However when I make changes to the event table it doesn’t show the changes I’ve made. I’m certain it has something to do with the way I’m retrieving the data.

SELECT CONCAT(u.lastname, ', ', u.firstname) AS Name
       , s.message AS Message
       , DATE_FORMAT(e.timestamp,'%b %d %Y - %r') AS DateTime
       , e.status AS Status 
FROM event e 
LEFT JOIN status s ON e.message_id = s.message_id
          , user u 
WHERE(e.user_id = u.user_id)
  AND event_id IN(
      SELECT MAX(e.event_id) FROM event e 
      GROUP BY e.user_id)
ORDER BY name

So I am in need of a new SQL query statement that will take the information in those three tables and produce a data grid view in my vb.net program that will look similar to this:

Resulting Table

But will also accept any changes I make to the database through the data grid view in my vb.net program; Or if my problem has nothing to do with the query statement, then I’d like to know how to fix this.

If you want to see the basic layout of my database (minus the personal information) then here is the script for my database.

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `in_out`;
USE `in_out`;
CREATE TABLE `admin_levels` (
  `level_id` tinyint(3) unsigned NOT NULL auto_increment,
  `title` char(20) NOT NULL default '',
  PRIMARY KEY  (`level_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `event` (
  `event_id` mediumint(8) unsigned NOT NULL auto_increment,
  `user_id` smallint(5) unsigned NOT NULL default '0',
  `message_id` mediumint(8) unsigned default '0',
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `status` enum('In','Out') NOT NULL default 'In',
  `creator` smallint(5) unsigned default NULL,
  PRIMARY KEY  (`event_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `event` (`event_id`,`user_id`,`message_id`,`timestamp`,`status`,`creator`) VALUES 
 (1,1,1,'2005-01-17 11:50:00','Out',1),
 (2,2,1,'2005-01-17 11:57:00','Out',2),
 (3,3,1,'2005-01-17 11:59:00','Out',3),
 (4,1,3,'2005-01-17 13:30:00','In',1),
 (5,2,3,'2005-01-17 13:30:00','In',2),
 (6,3,3,'2005-01-17 13:30:00','In',3),
 (7,2,2,'2005-01-17 16:00:00','Out',2),
 (8,3,2,'2005-01-17 16:10:00','Out',3),
 (9,1,NULL,'2005-01-17 15:19:49','In',1);
CREATE TABLE `groups` (
  `group_name` char(20) NOT NULL default '',
  `created` datetime NOT NULL default '0000-00-00 00:00:00',
  `scope` enum('Public','Private') default NULL,
  `deleted` enum('True','False') default NULL,
  PRIMARY KEY  (`group_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `status` (
  `message_id` mediumint(8) unsigned NOT NULL auto_increment,
  `user_id` smallint(5) unsigned default NULL,
  `message` char(255) NOT NULL default '',
  `deleted` enum('True','False') default NULL,
  PRIMARY KEY  (`message_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `status` (`message_id`,`user_id`,`message`,`deleted`) VALUES 
 (1,NULL,'Gone to Lunch','False'),
 (2,NULL,'Gone For The Day','False'),
 (3,NULL,'In Meeting','False');
CREATE TABLE `user` (
  `user_id` int(10) unsigned NOT NULL auto_increment,
  `lastname` char(40) NOT NULL default '',
  `firstname` char(40) NOT NULL default '',
  `phone` char(10) NOT NULL default '',
  `username` char(16) NOT NULL default '',
  `password` char(40) character set latin1 collate latin1_bin NOT NULL default '',
  `administrator` enum('TRUE','FALSE') NOT NULL default 'TRUE',
  `deleted` enum('TRUE','FALSE') NOT NULL default 'TRUE',
  `created` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
INSERT INTO `user` (`user_id`,`lastname`,`firstname`,`phone`,`username`,`password`,`administrator`,`deleted`,`created`) VALUES 
 (1,'Hillyer','Mike','4033806535','mike','12345','TRUE','FALSE','2004-11-27 11:41:00'),
 (2,'Jones','Tom','4035551212','bob','54321','FALSE','FALSE','2005-01-17 13:52:00'),
 (3,'Johnson','Julie','4035551213','julie','weakpass','FALSE','FALSE','2005-01-17 13:55:00');
CREATE TABLE `user_group` (
  `group_name` char(20) NOT NULL default '',
  `user_id` smallint(5) unsigned NOT NULL default '0',
  `level_id` tinyint(3) unsigned default NULL,
  PRIMARY KEY  (`user_id`,`group_name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  • 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-25T10:15:08+00:00Added an answer on May 25, 2026 at 10:15 am

    try this

     SELECT CONCAT(u.lastname + ', ' + u.firstname) AS Name
       , s.message AS Message
       , DATE_FORMAT(e.timestamp,'%b %d %Y - %r') AS DateTime
       , e.status AS Status 
    FROM event e 
    LEFT JOIN status s ON e.message_id = s.message_id inner join user u on e.user_id = u.user_id
    
    WHERE event_id IN(
      SELECT MAX(e.event_id) FROM event e 
      GROUP BY e.user_id)
    ORDER BY name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table set up on a mysql database called access with three
I have three tables tag , page , pagetag With the data below page
I have a MySql database with three tables I need to combine in a
I have a question regarding updating a MySQL database. I have three tables: Match,
I have in my MySQL database these two tables: CREATE TABLE IF NOT EXISTS
I have this big database on mysql (104 tables), where almost every single table
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables in the many-to-many format. I.e, table A, B, and AB
I have a MySQL Left Join problem. I have three tables which I'm trying
I have three tables called: users , facilities , and staff_facilities . users contains

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.