Jump to content

Latest owner query


xsist10

Recommended Posts

Hey guys

I have 2 tables in my system that allow me to trace requests from clients.
One table contains the information about the client and the other contains the ownership of the query. This allows the clients "query" to be passed back and forth between various peole inside the company.

Table information below (culled some fields for simplification)
[code]
CREATE TABLE  `query` (
  `id` int(11) NOT NULL auto_increment,
  `name` varchar(200) NOT NULL default '',
  `query` text NOT NULL,
  `created` datetime default NULL,
  `completed` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`id`)
);

CREATE TABLE  `query_trace` (
  `id` int(11) NOT NULL auto_increment,
  # corresponds to the entry in query table
  `query_id` int(11) NOT NULL default '0',
  `created` datetime default NULL,
  `completed` datetime NOT NULL default '0000-00-00 00:00:00',
  # the staff member this query has been passed to
  `owner` varchar(60) NOT NULL default '',
  PRIMARY KEY  (`id`)
);
[/code]

I want to query "query_trace" for a list of query_id's that belong to a specific owner only if it is the latest (created >) uncompleted (completed != "0000-00-00 00:00:00) entry.

Using GROUP BY query_id leaves me with the first entry for a specific query_id. I need to perform some kind of ORDER on the query before I cull un-needed entries.
Link to comment
https://forums.phpfreaks.com/topic/26804-latest-owner-query/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.