i want to insert new row in second table and this table connected to first table.
How can i do that?

By giving us some additional data like what is structure of these two tables?

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?

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

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.

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?

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

Anuone help on it...

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

yes i too thinking of trigger " after inserting in salary". but was not too sure...

Hello dharam if u know the concept of Primary and Foriegn key than it wil be very easy for u to maintain the things as you cant add any salary for an id that does not exist in parent table so rather than putting an trigger on it, it would be better if you use this concept.

commented: yes.... +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.