473,408 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Desperate for assistance on a join:

I have been working for a month (on and off) on the following issue:

The table contains event data, each event is placed in the table as
the event occurs, if there is never an event then there is never an
enttry for said event. When a device is down it is status 1 when it
comes back up the device becomes status 6. the newest status will have
a newer timestamp. So the objective is to write a querey that searches
that table for all the devices that are down (at this point in time).
Logically it would be select all the information from the table, where
the status is 1 and there is no newer event for that device. Here's
what I've come up with, however I get an error every single time. I'm
to the virge of snapping and I don't know why.
This is the create statement for the table:

CREATE TABLE `eventlog` (
`date_time` timestamp(14) NOT NULL,
`event_id` int(11) default NULL,
`priority` int(11) default NULL,
`message` varchar(255) default NULL,
`map_id` varchar(32) default NULL,
`agent_addr` varchar(16) default NULL,
`from_addr` varchar(16) default NULL,
`community` varchar(255) default NULL,
`enterprise` varchar(128) default NULL,
`up_time` int(11) default NULL,
`trap_oid` varchar(128) default NULL,
) TYPE=MyISAM;

here is my select:
Select d.* from
( select agent_addr, max(date_time) from eventlog where priority = 1
group by agent_addr) d,
(select agent_addr, max(date_time) from eventlog where priority = 6
group by agent_addr) u
where d.agent_addr = u.agent_addr
and d.date_time >= u.date_time
Here is the error:

[slaweb] ERROR 1064: You have an error in your SQL syntax. Check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'select agent_addr, max(date_time) from eventlog
where priority
Jul 20 '05 #1
1 1468
Joshua Goodstein wrote:
Logically it would be select all the information from the table, where
the status is 1 and there is no newer event for that device.
Try this query:

SELECT down.agent_addr, down.date_time
FROM eventlog AS down LEFT OUTER JOIN eventlog AS up
ON (down.agent_addr = came_up.agent_addr
AND up.date_time > down.date_time)
WHERE down.priority = 1 AND up.event_id IS NULL;
I get an error every single time. I'm
to the virge of snapping and I don't know why.


Subqueries are implemented in MySQL 4.1. If you're running an earlier
version, the subqueries you were using would cause an error.

Regards,
Bill K.
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luke Dubbber | last post by:
I am currently new to PHP and I am reading a book by Premier Press called PHP Professional Projects. I am new to PHP, I heard it was better and faster and way more flexible so far they have been...
0
by: Kevin Michael Reed | last post by:
------=_NextPart_000_002B_01C34DF8.C34C94F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Assistance required. I have 3 tables:
8
by: Tod Thames | last post by:
I currently have a sql statement that works great. I want to convert it to a stored procedure so I can generate results from a webpage. Below is the stored procedure that is working fine. ...
5
by: Kenneth Courville | last post by:
I have a couple of tables that look like this (not excactly but close enough): id int fname varchar(50) lname varchar(50) id int
5
by: Bill | last post by:
Good Day; I would appreciate assistance developing a query that I haven't been able to develop without using a second table. I wish to count the number of records that are still open on the...
7
by: KraftDiner | last post by:
The os.walk function walks the operating systems directory tree. This seems to work, but I don't quite understand the tupple that is returned... Can someone explain please? for root, dirs,...
6
by: shanevanle | last post by:
I have three tables ALIGNMENT ---------------- | store | region | ---------------- | 100 | 6 | ---------------- | 104 | 6 |
0
by: dolphinearth | last post by:
Hi all. I hope some of the smart fellow programmers can help me, please. The problem is I use Crystal Reports that was shipped out with VS 2005 .Net, and for some strange unknown reason, the...
1
by: shannonwhitty | last post by:
I am trying to obtain some data and I have a way to do it however it appears really longwinded and I'm sure there must be a better way to get this using a join of some type without such a complex...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.