I noticed a few mistakes in my query, which may be causing some
confusion and would probably cause it not to work. But I'll break
everything down.
The NULLs in the second owner column are the indicators that there is
no matching owner in the most recent three months.
Breaking down the query, t
The parts I am interested in:
(I won't bore you with the fields not relevant to this problem )
CREATE TABLE events (
e_id int(15) NOT NULL auto_increment,
e_owner int(15) NOT NULL default '0',
e_time int(15) NOT NULL default '0',
other junk omitted
PRIMARY KEY (e_id)
) TYPE=MyISA
Try something like this:
SELECT Events.ID, Events.ownerID, Owners.ownerID
FROM Events
LEFT JOIN Events AS Owners
ON Events.ownerID=Owners.ownerID AND Events.eventData> 3 months ago
WHERE Owners.ownerID IS NULL
I know you want to do a delete, but play with SELECT first to make sure
it's doing what
If you post the table structure (SHOW CREATE TABLE tablename\G) we could
help you write this statement.
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine
Gerald Taylor <[EMAIL PROTECTED]> wrote on 11/10/2004 11:52:35 AM:
> I have this table of events. Each event has an owner
>
I have this table of events. Each event has an owner
id and the time that it happened.
What I want to do is delete all events
more than three months old but only if the owner does not own
any newer events.
The coolest would just be a single DELETE query.
Can this be done?
Mysql 4.0.18
--
MySQL G
Perhaps I got my syntax wrong. IF() has been available since 3.23 as
far as I know. I find it more readable than case if I'm only doing a
single test, but either accomplishes what you need.
Here is the documentation for CASE and IF
http://dev.mysql.com/doc/mysql/en/Control_flow_functions.html
On
University ML
-Original Message-
From: news [mailto:[EMAIL PROTECTED] On Behalf Of Harald Fuchs
Sent: Thursday, June 03, 2004 10:23 PM
To: [EMAIL PROTECTED]
Subject: Re: Self-Join Query
In article
<[EMAIL PROTECTED]>,
"James KATARSKI" <[EMAIL PROTECTED]> writes:
> I&
In article <[EMAIL PROTECTED]>,
"James KATARSKI" <[EMAIL PROTECTED]> writes:
> I'm trying to generate a report like this: (Which I've done in TWO
> querys, the copied and pasted together)
> +-+--+--+
> | Page Name | Internal | External |
> +-+--+-
You may want to forget all those joins and filters to create two
columns, which is probably making MySQL do multiple full table scans.
It sounds like what you are really looking for is to separate your hits
into 2 columns based on the ip address, and perhaps put a filter on the
hit time or page
Hi All,
I'm attempting to generate a report of page hits from both internal and
external IP addresses, from one table, using self join.
Some sample data:
++-+++
| hit_no | page_name | ip | hit_time |
++-+
combinations.
Armand
---
Paal Eriksen wrote:
>Hi i have a challenge for you. I'm struggling with this self join query. I have a
>table which among several contains theese fields: id, strname, iparentid
>
>id is primary key and iparentid show who the child of id. There are 4 l
rel.id_activity=6
There are many other SELECT combinations.
Armand
---
Paal Eriksen wrote:
Hi i have a challenge for you. I'm struggling with this self join query. I have a table which among several contains theese fields: id, st
Hi i have a challenge for you. I'm struggling with this self join query. I have a
table which among several contains theese fields: id, strname, iparentid
id is primary key and iparentid show who the child of id. There are 4 level deepth in
this table, i.e. like this
iIDst
13 matches
Mail list logo