Re: How to merge my tables?

2006-03-31 Thread Johan Lundqvist

I LOVE YOU!!!

Great way of doing it. Never thought of creating that extra table and 
match against it... You really saved my day!!


Now I just have to get rid of those rows containing nothing but NULL 
values (if I select years 2000 ... 2003 empl_id 1002 generates a row 
with all columns = NULL).


I'll look in to it tomorrow, it's in the midddle of the night here and 
soon my backup system will start = no access to my server...


Thanx again, this really got my out of my mindlock.

Regards,
/Johan

Shaunak Kashyap wrote:

OK. No problem. We can hopefully still make this work with a temporary
table.

The SQL will look something like this:

CREATE TEMPORARY TABLE tmp_sales_rep
SELECT empl_id FROM Table_1998
UNION
SELECT empl_id FROM Table_1999
UNION
SELECT empl_id FROM Table_2000

SELECT t.empl_id, t98.sales98, t99.sales99, t00.sales00
FROM   tmp_sales_rep AS t
LEFT JOIN Table_1998 AS t98 ON t.empl_id = t98.empl_id
LEFT JOIN Table_1999 AS t99 ON t.empl_id = t99.empl_id
LEFT JOIN Table_2000 AS t00 ON t.empl_id = t00.empl_id

Hope that helps,

Shaunak Kashyap
 
Senior Web Developer

WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036
 
Direct: 323.330.9870

Main: 323.330.9900
 
www.worldpokertour.com
 
Confidentiality Notice:  This e-mail transmission (and/or the

attachments accompanying) it may contain confidential information
belonging to the sender which is protected.  The information is intended
only for the use of the intended recipient.  If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or taking of any action in reliance on the contents of this
information is prohibited. If you have received this transmission in
error, please notify the sender by reply e-mail and destroy all copies
of this transmission.



-Original Message-
From: Johan Lundqvist [mailto:[EMAIL PROTECTED]
Sent: Friday, March 31, 2006 2:07 PM
To: mysql@lists.mysql.com
Subject: Re: How to merge my tables?

No, I don't have that. There's about 5-10% change in employees ids

from

every year, and no one took any interest in this system before I got

it

in my lap...
Would it help to have one??

Shaunak Kashyap wrote:

Do you have a table that has *all* your employees ids (empl_id)?

Shaunak Kashyap

Senior Web Developer
WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036

Direct: 323.330.9870
Main: 323.330.9900

www.worldpokertour.com

Confidentiality Notice:  This e-mail transmission (and/or the
attachments accompanying) it may contain confidential information
belonging to the sender which is protected.  The information is

intended

only for the use of the intended recipient.  If you are not the

intended

recipient, you are hereby notified that any disclosure, copying,
distribution or taking of any action in reliance on the contents of

this

information is prohibited. If you have received this transmission in
error, please notify the sender by reply e-mail and destroy all

copies

of this transmission.



-Original Message-
From: Johan Lundqvist [mailto:[EMAIL PROTECTED]
Sent: Friday, March 31, 2006 1:13 PM
To: mysql@lists.mysql.com
Subject: How to merge my tables?

Hi,
I hope this is the right forum for this question. If not, I'm happy

to

get some tip on where to post this.

My problem:
I have like 20 tables of data and need to merge these, making a
selection, (and dump it into a text file) to import into a

reporting

tool. The tables is like salesrep, value of sales, number of

customers,

and som series of codes. If I do a JOIN, I only get the salesreps

that

exist in that specific table, but new people are added and some

have

left the company. How can this be done??


A short example of the data:

Table_1998:
empl_id | sales98 | customers98 | etc98 | ...
1001 |   12659 | 123 |   | ...
1002 |  103674 | 597 | hued  | ...
1003 |   23589 | 314 | hjeoir| ...

Table_1999:
empl_id | sales99 | customers99 | etc99 | ...
1001 |   35678 | 213 | dwrer | ...
1002 |  125795 | 603 | freui | ...
1003 |   45678 | 343 | hfiwu | ...
1004 |8753 |  96 | poijo | ...

Table_2000:
empl_id | sales00 | customers00 | etc00 | ...
1001 |   97361 | 526 | urhfn | ...
1003 |   98716 | 649 | jdwoh | ...
1004 |   15872 | 147 | oijnm | ...

Now I try to get the customersXX columns for every emloyee from

these

tables.
What I would like to see in my result:
empl_id | customers98 | customers99 | customers00 | ...
1001 | 123 | 213 | 526 | ...
1002 | 597 | 603 |NULL | ...
1003 | 314 | 343 | 649 | ...
1004 |NULL |  96 | 147 | ...


I've tried everything and I'm out of clues.
Can it be done?? If so, how???

Any help/tips are very welcome!!

/Johan, Uppsala - Sweden

--

RE: How to merge my tables?

2006-03-31 Thread Shaunak Kashyap
OK. No problem. We can hopefully still make this work with a temporary
table.

The SQL will look something like this:

CREATE TEMPORARY TABLE tmp_sales_rep
SELECT empl_id FROM Table_1998
UNION
SELECT empl_id FROM Table_1999
UNION
SELECT empl_id FROM Table_2000

SELECT t.empl_id, t98.sales98, t99.sales99, t00.sales00
FROM   tmp_sales_rep AS t
LEFT JOIN Table_1998 AS t98 ON t.empl_id = t98.empl_id
LEFT JOIN Table_1999 AS t99 ON t.empl_id = t99.empl_id
LEFT JOIN Table_2000 AS t00 ON t.empl_id = t00.empl_id

Hope that helps,

Shaunak Kashyap
 
Senior Web Developer
WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036
 
Direct: 323.330.9870
Main: 323.330.9900
 
www.worldpokertour.com
 
Confidentiality Notice:  This e-mail transmission (and/or the
attachments accompanying) it may contain confidential information
belonging to the sender which is protected.  The information is intended
only for the use of the intended recipient.  If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or taking of any action in reliance on the contents of this
information is prohibited. If you have received this transmission in
error, please notify the sender by reply e-mail and destroy all copies
of this transmission.


> -Original Message-
> From: Johan Lundqvist [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 31, 2006 2:07 PM
> To: mysql@lists.mysql.com
> Subject: Re: How to merge my tables?
> 
> No, I don't have that. There's about 5-10% change in employees ids
from
> every year, and no one took any interest in this system before I got
it
> in my lap...
> Would it help to have one??
> 
> Shaunak Kashyap wrote:
> > Do you have a table that has *all* your employees ids (empl_id)?
> >
> > Shaunak Kashyap
> >
> > Senior Web Developer
> > WPT Enterprises, Inc.
> > 5700 Wilshire Blvd., Suite 350
> > Los Angeles, CA 90036
> >
> > Direct: 323.330.9870
> > Main: 323.330.9900
> >
> > www.worldpokertour.com
> >
> > Confidentiality Notice:  This e-mail transmission (and/or the
> > attachments accompanying) it may contain confidential information
> > belonging to the sender which is protected.  The information is
intended
> > only for the use of the intended recipient.  If you are not the
intended
> > recipient, you are hereby notified that any disclosure, copying,
> > distribution or taking of any action in reliance on the contents of
this
> > information is prohibited. If you have received this transmission in
> > error, please notify the sender by reply e-mail and destroy all
copies
> > of this transmission.
> >
> >
> >> -Original Message-
> >> From: Johan Lundqvist [mailto:[EMAIL PROTECTED]
> >> Sent: Friday, March 31, 2006 1:13 PM
> >> To: mysql@lists.mysql.com
> >> Subject: How to merge my tables?
> >>
> >> Hi,
> >> I hope this is the right forum for this question. If not, I'm happy
to
> >> get some tip on where to post this.
> >>
> >> My problem:
> >> I have like 20 tables of data and need to merge these, making a
> >> selection, (and dump it into a text file) to import into a
reporting
> >> tool. The tables is like salesrep, value of sales, number of
> > customers,
> >> and som series of codes. If I do a JOIN, I only get the salesreps
that
> >> exist in that specific table, but new people are added and some
have
> >> left the company. How can this be done??
> >>
> >>
> >> A short example of the data:
> >>
> >> Table_1998:
> >> empl_id | sales98 | customers98 | etc98 | ...
> >> 1001 |   12659 | 123 |   | ...
> >> 1002 |  103674 | 597 | hued  | ...
> >> 1003 |   23589 | 314 | hjeoir| ...
> >>
> >> Table_1999:
> >> empl_id | sales99 | customers99 | etc99 | ...
> >> 1001 |   35678 | 213 | dwrer | ...
> >> 1002 |  125795 | 603 | freui | ...
> >> 1003 |   45678 | 343 | hfiwu | ...
> >> 1004 |8753 |  96 | poijo | ...
> >>
> >> Table_2000:
> >> empl_id | sales00 | customers00 | etc00 | ...
> >> 1001 |   97361 | 526 | urhfn | ...
> >> 1003 |   98716 | 649 | jdwoh | ...
> >> 1004 |   15872 | 147 | oijnm | ...
> >>
> >> Now I try to get the customersXX columns for every emloyee from
these
> >> tables.
> >> What I would like to see in my result:
> >> empl_id | customers98 | customers99 | customers00 | ...
> >> 1001 | 1

Re: How to merge my tables?

2006-03-31 Thread Johan Lundqvist
No, I don't have that. There's about 5-10% change in employees ids from 
every year, and no one took any interest in this system before I got it 
in my lap...

Would it help to have one??

Shaunak Kashyap wrote:

Do you have a table that has *all* your employees ids (empl_id)?

Shaunak Kashyap
 
Senior Web Developer

WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036
 
Direct: 323.330.9870

Main: 323.330.9900
 
www.worldpokertour.com
 
Confidentiality Notice:  This e-mail transmission (and/or the

attachments accompanying) it may contain confidential information
belonging to the sender which is protected.  The information is intended
only for the use of the intended recipient.  If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or taking of any action in reliance on the contents of this
information is prohibited. If you have received this transmission in
error, please notify the sender by reply e-mail and destroy all copies
of this transmission.



-Original Message-
From: Johan Lundqvist [mailto:[EMAIL PROTECTED]
Sent: Friday, March 31, 2006 1:13 PM
To: mysql@lists.mysql.com
Subject: How to merge my tables?

Hi,
I hope this is the right forum for this question. If not, I'm happy to
get some tip on where to post this.

My problem:
I have like 20 tables of data and need to merge these, making a
selection, (and dump it into a text file) to import into a reporting
tool. The tables is like salesrep, value of sales, number of

customers,

and som series of codes. If I do a JOIN, I only get the salesreps that
exist in that specific table, but new people are added and some have
left the company. How can this be done??


A short example of the data:

Table_1998:
empl_id | sales98 | customers98 | etc98 | ...
1001 |   12659 | 123 |   | ...
1002 |  103674 | 597 | hued  | ...
1003 |   23589 | 314 | hjeoir| ...

Table_1999:
empl_id | sales99 | customers99 | etc99 | ...
1001 |   35678 | 213 | dwrer | ...
1002 |  125795 | 603 | freui | ...
1003 |   45678 | 343 | hfiwu | ...
1004 |8753 |  96 | poijo | ...

Table_2000:
empl_id | sales00 | customers00 | etc00 | ...
1001 |   97361 | 526 | urhfn | ...
1003 |   98716 | 649 | jdwoh | ...
1004 |   15872 | 147 | oijnm | ...

Now I try to get the customersXX columns for every emloyee from these
tables.
What I would like to see in my result:
empl_id | customers98 | customers99 | customers00 | ...
1001 | 123 | 213 | 526 | ...
1002 | 597 | 603 |NULL | ...
1003 | 314 | 343 | 649 | ...
1004 |NULL |  96 | 147 | ...


I've tried everything and I'm out of clues.
Can it be done?? If so, how???

Any help/tips are very welcome!!

/Johan, Uppsala - Sweden

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



RE: How to merge my tables?

2006-03-31 Thread Shaunak Kashyap
Do you have a table that has *all* your employees ids (empl_id)?

Shaunak Kashyap
 
Senior Web Developer
WPT Enterprises, Inc.
5700 Wilshire Blvd., Suite 350
Los Angeles, CA 90036
 
Direct: 323.330.9870
Main: 323.330.9900
 
www.worldpokertour.com
 
Confidentiality Notice:  This e-mail transmission (and/or the
attachments accompanying) it may contain confidential information
belonging to the sender which is protected.  The information is intended
only for the use of the intended recipient.  If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or taking of any action in reliance on the contents of this
information is prohibited. If you have received this transmission in
error, please notify the sender by reply e-mail and destroy all copies
of this transmission.


> -Original Message-
> From: Johan Lundqvist [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 31, 2006 1:13 PM
> To: mysql@lists.mysql.com
> Subject: How to merge my tables?
> 
> Hi,
> I hope this is the right forum for this question. If not, I'm happy to
> get some tip on where to post this.
> 
> My problem:
> I have like 20 tables of data and need to merge these, making a
> selection, (and dump it into a text file) to import into a reporting
> tool. The tables is like salesrep, value of sales, number of
customers,
> and som series of codes. If I do a JOIN, I only get the salesreps that
> exist in that specific table, but new people are added and some have
> left the company. How can this be done??
> 
> 
> A short example of the data:
> 
> Table_1998:
> empl_id | sales98 | customers98 | etc98 | ...
> 1001 |   12659 | 123 |   | ...
> 1002 |  103674 | 597 | hued  | ...
> 1003 |   23589 | 314 | hjeoir| ...
> 
> Table_1999:
> empl_id | sales99 | customers99 | etc99 | ...
> 1001 |   35678 | 213 | dwrer | ...
> 1002 |  125795 | 603 | freui | ...
> 1003 |   45678 | 343 | hfiwu | ...
> 1004 |8753 |  96 | poijo | ...
> 
> Table_2000:
> empl_id | sales00 | customers00 | etc00 | ...
> 1001 |   97361 | 526 | urhfn | ...
> 1003 |   98716 | 649 | jdwoh | ...
> 1004 |   15872 | 147 | oijnm | ...
> 
> Now I try to get the customersXX columns for every emloyee from these
> tables.
> What I would like to see in my result:
> empl_id | customers98 | customers99 | customers00 | ...
> 1001 | 123 | 213 | 526 | ...
> 1002 | 597 | 603 |NULL | ...
> 1003 | 314 | 343 | 649 | ...
> 1004 |NULL |  96 | 147 | ...
> 
> 
> I've tried everything and I'm out of clues.
> Can it be done?? If so, how???
> 
> Any help/tips are very welcome!!
> 
> /Johan, Uppsala - Sweden
> 
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



How to merge my tables?

2006-03-31 Thread Johan Lundqvist

Hi,
I hope this is the right forum for this question. If not, I'm happy to 
get some tip on where to post this.


My problem:
I have like 20 tables of data and need to merge these, making a 
selection, (and dump it into a text file) to import into a reporting 
tool. The tables is like salesrep, value of sales, number of customers, 
and som series of codes. If I do a JOIN, I only get the salesreps that 
exist in that specific table, but new people are added and some have 
left the company. How can this be done??



A short example of the data:

Table_1998:
empl_id | sales98 | customers98 | etc98 | ...
   1001 |   12659 | 123 |   | ...
   1002 |  103674 | 597 | hued  | ...
   1003 |   23589 | 314 | hjeoir| ...

Table_1999:
empl_id | sales99 | customers99 | etc99 | ...
   1001 |   35678 | 213 | dwrer | ...
   1002 |  125795 | 603 | freui | ...
   1003 |   45678 | 343 | hfiwu | ...
   1004 |8753 |  96 | poijo | ...

Table_2000:
empl_id | sales00 | customers00 | etc00 | ...
   1001 |   97361 | 526 | urhfn | ...
   1003 |   98716 | 649 | jdwoh | ...
   1004 |   15872 | 147 | oijnm | ...

Now I try to get the customersXX columns for every emloyee from these 
tables.

What I would like to see in my result:
empl_id | customers98 | customers99 | customers00 | ...
   1001 | 123 | 213 | 526 | ...
   1002 | 597 | 603 |NULL | ...
   1003 | 314 | 343 | 649 | ...
   1004 |NULL |  96 | 147 | ...


I've tried everything and I'm out of clues.
Can it be done?? If so, how???

Any help/tips are very welcome!!

/Johan, Uppsala - Sweden

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]