Hi
I have 3 tables with the same fields.
I would want to find the data that they are comprised in the time interval:
SELECT a.*, b.*, c.*
FROM tab1 a, tab2 b, tab3 c
WHERE a.date between '-MM-DD' and '-MM-DD'
OR b.date between '-MM-DD' and '-MM-DD'
OR c.date between
On Wed, October 18, 2006 12:46, spacemarc said:
Hi
I have 3 tables with the same fields.
I would want to find the data that they are comprised in the time
interval:
SELECT a.*, b.*, c.*
FROM tab1 a, tab2 b, tab3 c
WHERE a.date between '-MM-DD' and '-MM-DD'
OR b.date between
Cartesian Join Anyone ???
Rearrange Query as a UNION instead
- Original Message -
From: spacemarc [EMAIL PROTECTED]
To: mysql@lists.mysql.com
Sent: Wednesday, October 18, 2006 3:46:04 PM GMT-0500 US/Eastern
Subject: Simple JOIN on three tables
Hi
I have 3 tables with the same fields
ok, instead I use
(SELECT * FROM tab1 WHERE mydate between 'the-date1' and 'the-date2' )
UNION
(SELECT * FROM tab2 WHERE mydate between 'the-date1' and 'the-date2' )
etc
But if I wanted to use a join I can make it however or not?
--
http://www.spacemarc.it
--
MySQL General Mailing List
But if I wanted to use a join I can make it however or not?
You can join on any row(s) you like. What are you trying to acccomplish?
PB
spacemarc wrote:
ok, instead I use
(SELECT * FROM tab1 WHERE mydate between 'the-date1' and 'the-date2' )
UNION
(SELECT * FROM tab2 WHERE mydate between
On Wed, October 18, 2006 13:21, spacemarc said:
ok, instead I use
(SELECT * FROM tab1 WHERE mydate between 'the-date1' and 'the-date2' )
UNION
(SELECT * FROM tab2 WHERE mydate between 'the-date1' and 'the-date2' )
etc
But if I wanted to use a join I can make it however or not?
--
2006/10/18, Peter Brawley [EMAIL PROTECTED]:
You can join on any row(s) you like. What are you trying to acccomplish?
I simply want to select the records from my three tables that are
comprised in time interval.
Now, the first table comprises the records until to 2004 year; the
second table
On Wed, October 18, 2006 13:37, spacemarc said:
2006/10/18, Peter Brawley [EMAIL PROTECTED]:
You can join on any row(s) you like. What are you trying to acccomplish?
I simply want to select the records from my three tables that are
comprised in time interval.
Now, the first table comprises
2006/10/18, William R. Mussatto [EMAIL PROTECTED]:
Then it is really a UNION. I hope you have the date field as an index
otherwise you are looking at a table scan which is always slow.
Ok, if I have the field ID that have the same value in three tables
but I want to select however the data
I simply want to select the records from my three tables that are
comprised in time interval.
If you want the results in one resultset, apply an appropriate Where
clause to each year-table query and union the queries, eg
SELECT * FROM a WHERE date BETWEEN '2004-3-1' AND '2004-6-30'
UNION
You can join on any row(s) you like. What are you trying to acccomplish?
I simply want to select the records from my three tables that are
comprised in time interval.
Now, the first table comprises the records until to 2004 year; the
second table unitl 2005 and the third table until 2006.
11 matches
Mail list logo