Insert value from one table to 2nd table [message #602774] |
Mon, 09 December 2013 00:10 |
haider_1pk
Messages: 135 Registered: March 2009 Location: PAKISTAN
|
Senior Member |
|
|
Hello,
I need your help about inserting values from one table to 2nd table. When insert values to 2nd table then add value in stock_id . I mean plus in max (stock_id) .
Check in 2nd table we have max stock_id is 8.
Now I need result after inserting or updating.
stock_d principle_id Date Bill
9 303 9-Dec-13 Paid
10 603 9-Dec-13 Paid
11 1406 9-Dec-13 Paid
12 3 9-Dec-13 Paid
13 1443 9-Dec-13 Paid
14 1445 9-Dec-13 Paid
15 1446 9-Dec-13 Paid
16 1450 9-Dec-13 Paid
17 1451 9-Dec-13 Paid
18 1452 9-Dec-13 Paid
19 1453 9-Dec-13 Paid
20 1454 9-Dec-13 Paid
21 1455 9-Dec-13 Paid
22 1456 9-Dec-13 Paid
23 1468 9-Dec-13 Paid
Here is table Details
SQL> desc principle
Name Null? Type
------------------------------- -------- ----
PRINCIPLE_ID NOT NULL NUMBER(4)
PRINCIPLE_NAME NOT NULL VARCHAR2(100)
PHONE_NO VARCHAR2(13)
ADDRESS VARCHAR2(50)
COM_ID VARCHAR2(20)
SQL>
1 select principle_id,com_id from principle
2* where com_id=1
SQL> /
PRINCIPLE_ID COM_ID
------------ --------------------
303 1
603 1
1406 1
3 1
1443 1
1445 1
1446 1
1450 1
1451 1
1452 1
1453 1
1454 1
1455 1
1456 1
1468 1
15 rows selected.
SQL> desc stock_in
Name Null? Type
------------------------------- -------- ----
STOCK_ID NOT NULL NUMBER(4)
PRINCIPLE_ID NOT NULL NUMBER(4)
WDATE DATE
PAID VARCHAR2(10)
INV NUMBER(20)
TNO VARCHAR2(50)
1* select stock_id,principle_id,wdate, paid from stock_in
STOCK_ID PRINCIPLE_ID WDATE PAID
--------- ------------ --------- ----------
1 402 29-JUN-13 Paid
4 402 02-DEC-13 Paid
2 402 02-DEC-13 Paid
3 1406 02-DEC-13 Unpaid
5 1406 02-DEC-13 Paid
6 1406 04-DEC-13 Paid
7 1450 04-DEC-13 Paid
8 303 04-DEC-13 Paid
8 rows selected.
SQL>
[Updated on: Mon, 09 December 2013 00:12] Report message to a moderator
|
|
|
|
|
Re: Insert value from one table to 2nd table [message #602778 is a reply to message #602777] |
Mon, 09 December 2013 00:52 |
haider_1pk
Messages: 135 Registered: March 2009 Location: PAKISTAN
|
Senior Member |
|
|
Hello Sir,
I have two tables of Principle and stock_in .
I just want to get from principle table chose the value of principle_id and use where condition on com_id. those value insert into stock_in table.But add in stock_in where
stock_id is maximum and also insert sysdate and bill type that is paid.
Hope u will understand .
Thanks
|
|
|
|