943,678 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 1710
  • MySQL RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 6th, 2008
0

hOW TO INSERT NEW RECORD IN SEC TABLE?

Expand Post »
i want to insert new row in second table and this table connected to first table.
How can i do that?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dharam_05 is offline Offline
22 posts
since Aug 2008
Aug 6th, 2008
-1

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

By giving us some additional data like what is structure of these two tables?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,654 posts
since Dec 2004
Aug 7th, 2008
0

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

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?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dharam_05 is offline Offline
22 posts
since Aug 2008
Aug 7th, 2008
-1

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

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
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,654 posts
since Dec 2004
Aug 7th, 2008
0

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dharam_05 is offline Offline
22 posts
since Aug 2008
Aug 7th, 2008
-1

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

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?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,654 posts
since Dec 2004
Aug 7th, 2008
0

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dharam_05 is offline Offline
22 posts
since Aug 2008
Aug 8th, 2008
0

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

Anuone help on it...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dharam_05 is offline Offline
22 posts
since Aug 2008
Aug 8th, 2008
-1

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

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
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 871
Code tags enforcer
peter_budo is offline Offline
6,654 posts
since Dec 2004
Aug 8th, 2008
0

Re: hOW TO INSERT NEW RECORD IN SEC TABLE?

yes i too thinking of trigger " after inserting in salary". but was not too sure...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dharam_05 is offline Offline
22 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: In Mysql Storing and retriving the image with asp.net
Next Thread in MySQL Forum Timeline: Best way to query





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC