hOW TO INSERT NEW RECORD IN SEC TABLE?

Reply

Join Date: Aug 2008
Posts: 22
Reputation: dharam_05 is an unknown quantity at this point 
Solved Threads: 0
dharam_05 dharam_05 is offline Offline
Newbie Poster

hOW TO INSERT NEW RECORD IN SEC TABLE?

 
0
  #1
Aug 6th, 2008
i want to insert new row in second table and this table connected to first table.
How can i do that?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,200
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 486
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
-1
  #2
Aug 6th, 2008
By giving us some additional data like what is structure of these two tables?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 22
Reputation: dharam_05 is an unknown quantity at this point 
Solved Threads: 0
dharam_05 dharam_05 is offline Offline
Newbie Poster

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
0
  #3
Aug 7th, 2008
There are two tables:
1) Emp table with fields.
Emp_id, Emp_name,Dept.
2) Salary table with fields.
Emp_id, Salary.

I want to insert new record in salary table, if i insert rec in salary table it should also update in first table.
How i can do this?
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,200
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 486
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
-1
  #4
Aug 7th, 2008
There is nothing to update in first table Emp_id what links both tables. So if you trying to get salary of an employee you either have already person's ID or you will find out through matching of employee name and department against Emp table. Once you get that ID then you can query salary table for that person salary
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 22
Reputation: dharam_05 is an unknown quantity at this point 
Solved Threads: 0
dharam_05 dharam_05 is offline Offline
Newbie Poster

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
0
  #5
Aug 7th, 2008
i dont want to fetch the records i just want to insert new rec in sec table's field so when i enter new Emp_id in salary table then this Emp_id should also be reflected in first table.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,200
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 486
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
-1
  #6
Aug 7th, 2008
There is nothing to reflect in first table. In reality you do want to only update salary in salary table. If you start adding new salaries with same employee ID how do will you find what is that person actual salary from numerous records you will have?
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 22
Reputation: dharam_05 is an unknown quantity at this point 
Solved Threads: 0
dharam_05 dharam_05 is offline Offline
Newbie Poster

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
0
  #7
Aug 7th, 2008
Ya with the same Emp_id it will be ok but i wanta dd new Emp_id in sec table..
just want give more info like:

Emp table
Emp_id Emp_name
1 ABC
2 EFG

Salary table

Emp_id Salary
1 1000
2 2000

Now i want insert new rec in salary table with new Emp_id = 3 and salary = 3000;
I want Emp_id 3 should also reflect in first table as far as Emp_name concern it will null.
This is my Query.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 22
Reputation: dharam_05 is an unknown quantity at this point 
Solved Threads: 0
dharam_05 dharam_05 is offline Offline
Newbie Poster

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
0
  #8
Aug 8th, 2008
Anuone help on it...
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,200
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 486
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
-1
  #9
Aug 8th, 2008
There is option to use triggers, but so far I had no time to test how does it work, or execute 2 insert statements one after other with same Emp_id
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 22
Reputation: dharam_05 is an unknown quantity at this point 
Solved Threads: 0
dharam_05 dharam_05 is offline Offline
Newbie Poster

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

 
0
  #10
Aug 8th, 2008
yes i too thinking of trigger " after inserting in salary". but was not too sure...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the MySQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC