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