Hello all,
I am still relatively new to MySQL and databases in general. I am working on populating a mastertable for Human Resource and have developed a series of MySQL commands to accomplish this. I would like to automate this as much as possible.
Is there a way to link several different SQL commands together?
Many commands rely on the command prior to it.
Just for reference, these are the commands that I am using.
(Find new records and insert into Mastertable) insert into `mastertable2` select 0302_2500.ssn, 0302_2500.vsssn, 0302_2500.name_ind, 0302_2500.pay_gr_aa, '0302', '30000' from Mastertable2 right join 0302_2500 on mastertable2.ssn = 0302_2500.SSN where (((if(mastertable2.ssn=0302_2500.ssn, 0, 1))=1))
(Find records with changes and insert into Transition table) insert into transition2 select 0302_2500.ssn, 0302_2500.vsssn, 0302_2500.name_ind, 0302.pay_gr_aa, '0302', '1001' from 0302_2500, mastertable2 where mastertable2.ssn=0302_2500.ssn and ((((if(mastertable2.vsssn=0302_2500.vsssn, 0, 1))=1)) or (((if(mastertable2.name_ind=0302_2500.name_ind, 0, 1))=1)))
(Match Mastertable to transition and update mastertable Date_end) Update `mastertable2`, transition2 set mastertable2.date_end=(transition2.date_start-1) where mastertable2.ssn=transition2.ssn and mastertable2.date_end=transition2.`Date_end`
(Insert changed records of transition table into mastertable) Insert into `mastertable2` select * from `transition2`
(Delete records from transition table) Delete from transition2 where ssn>0
3 4201
Hello all,
I am still relatively new to MySQL and databases in general. I am working on populating a mastertable for Human Resource and have developed a series of MySQL commands to accomplish this. I would like to automate this as much as possible.
Is there a way to link several different SQL commands together?
Many commands rely on the command prior to it.
Just for reference, these are the commands that I am using.
(Find new records and insert into Mastertable) insert into `mastertable2` select 0302_2500.ssn, 0302_2500.vsssn, 0302_2500.name_ind, 0302_2500.pay_gr_aa, '0302', '30000' from Mastertable2 right join 0302_2500 on mastertable2.ssn = 0302_2500.SSN where (((if(mastertable2.ssn=0302_2500.ssn, 0, 1))=1))
(Find records with changes and insert into Transition table) insert into transition2 select 0302_2500.ssn, 0302_2500.vsssn, 0302_2500.name_ind, 0302.pay_gr_aa, '0302', '1001' from 0302_2500, mastertable2 where mastertable2.ssn=0302_2500.ssn and ((((if(mastertable2.vsssn=0302_2500.vsssn, 0, 1))=1)) or (((if(mastertable2.name_ind=0302_2500.name_ind, 0, 1))=1)))
(Match Mastertable to transition and update mastertable Date_end) Update `mastertable2`, transition2 set mastertable2.date_end=(transition2.date_start-1) where mastertable2.ssn=transition2.ssn and mastertable2.date_end=transition2.`Date_end`
(Insert changed records of transition table into mastertable) Insert into `mastertable2` select * from `transition2`
(Delete records from transition table) Delete from transition2 where ssn>0
That can now be done by grouping the statements into a procedure.
That can now be done by grouping the statements into a procedure.
Thanks, thats exactly what I needed. I believe that my biggest problem is figuring out what everything is called :) thanks for the help.
Thanks, thats exactly what I needed. I believe that my biggest problem is figuring out what everything is called :) thanks for the help.
The more you write the codes the more terms you'll get to know.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Steve Steward |
last post by:
I'm trying to create a generic object that will work for several
different types of databases. Does anyone know why this won't work?
// Connect to the database
$cmd = $this->db_type . "_connect...
|
by: phpfrizzle |
last post by:
Hi there,
I have a site with products on it.
The site has a mysql backend.
All products belong to certain series (table series).
There can be up to 4 different products (table products)...
|
by: Dave Moore |
last post by:
Hi All,
I'm looking at using PHP and MySQL for a particular website application.
However, I was a bit concerned that if a PHP script went wrong then it would
be possible to accidentally delete or...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest...
|
by: Sai Hertz And Control Systems |
last post by:
Dear all,
Their was a huge rore about MySQL recently for something in java functions
now theirs one more
http://www.mysql.com/doc/en/News-5.0.x.html
Does this concern anyone.
What I...
|
by: Karuna |
last post by:
Hi,
I am new to MySQL. I want to create a script file which will include a
number of commands and execute it, just like we do in Oracle. Can any
one tell me how to do it?
Suppose I want to create...
|
by: alf |
last post by:
Hi,
is it possible that due to OS crash or mysql itself crash or some e.g.
SCSI failure to lose all the data stored in the table (let's say million
of 1KB rows). In other words what is the worst...
|
by: Atli |
last post by:
This is an easy to digest 12 step guide on basics of using MySQL. It's a great refresher for those who need it and it work's great for first time MySQL users.
Anyone should be able to get...
|
by: realin |
last post by:
hi guys,
well this time i need to ask something related to database and php. I want to make certain insert statements in multiple tables and i want that to do that
a more consistent way. Just...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |