Home » SQL & PL/SQL » SQL & PL/SQL » Join in Insert
Join in Insert [message #584896] Mon, 20 May 2013 07:01 Go to next message
Taha
Messages: 8
Registered: February 2009
Location: Karachi
Junior Member
Hi

I am trying to insert records in multiple tables. I know how to view data using joinig, but unable to understand how to insert records in multiple tables using Joining. I searched it on net, but didn't find much. I have also tried to write a code, but it is not working, I have seen some examples on different websites where people are using SELECT in INSERT statement for joining. Kindly tell me the correct Syntax to INSERT record in Multiple tables.

Insert into library_users, library_users_info
(library_users.username, library_users.password, library_users_info.address, library_users_info.phone_no) VALUES (...)


[Updated on: Mon, 20 May 2013 07:02]

Report message to a moderator

Re: Join in Insert [message #584899 is a reply to message #584896] Mon, 20 May 2013 07:06 Go to previous messageGo to next message
Littlefoot
Messages: 19770
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You can't do that. INSERT works with a single table only (unless you insert into a view, whose INSTEAD OF triggers do additional job and insert into different tables). Though, you could use INSERT ALL, such as
insert all
  into library_users (username, password) values ('lf', 'pwd')
  into library_users_info (address, phone_no) values ('croatia', '12345')
select * from dual
Re: Join in Insert [message #584901 is a reply to message #584896] Mon, 20 May 2013 07:09 Go to previous message
Solomon Yakobson
Messages: 2060
Registered: January 2010
Senior Member
Did you read documentation? Look for multi table insert under INSERT

SY.
Previous Topic: Understanding Primary Key/Composite Key
Next Topic: utl_file error
Goto Forum:
  


Current Time: Sat Nov 22 18:13:19 CST 2014

Total time taken to generate the page: 0.09336 seconds