-
SQL Insert data in Multiple table and Update at same time
Hi
I have a question about How to insert and update data using Multiple tables . I need to insert data into two SQL table from one query ( insert statement ) and able to update that tables with a one update command . How do I do that . I think I have to use Inner jnoin but it is not working . Can any one give me the syntax of the SQL statement . I am using SQL server 2000 .
Thanks
-
I believe you may only INSERT into or UPDATE one table per SQL statement. You may, however, include multiple statements in a single query; separate the statement with a semi-colon.
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
Insert and update multiple tables at at time
Hi
Thanks for your reply . It worked . I can insert and update multiple SQL Server table at same time now
Thanks
-
Hi,
I am trying to do something similar, but have not been able to figure out how to insert data on two different tables from one submission form.
For example, I have a form that asks for the following data (from users registering):
Username
Password
Email Address
I would like to insert username and password in one table (table1) and the email address in a different table (table2).
I am using PHP/MySQL for this.
How would I insert data from one form into two tables?
Thanks for you help,
Ray
-
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
I'm really struggling with inserting data to more than one table from a single form as well. Starting to think it might make more sense to load all the form data to a single table and query just the single. If inserting INTO more than one table is this much hassle, I can only imagine how successfully querying OUT OF more than one will be. ;-) Has anyone seen any good tutorials with examples for PHP and MySQL on the net?
-
How to insert records into both the tables in a "single query" in SQL SERVER 2005
-
Welcome to DevX 
 Originally Posted by ramakrishnan
How to insert records into both the tables in a "single query" in SQL SERVER 2005
I believe this still applies.
 Originally Posted by Phil Weber
I believe you may only INSERT into or UPDATE one table per SQL statement. You may, however, include multiple statements in a single query; separate the statement with a semi-colon.
Any particular reason why you don't want to use more than one SQL statement?
-
Phil's feedback would be a tad clearer if it said you can string one SQL statement after another, seperated by semi-colons (for those who do not yet really understand that multiple SQL Statements can make up a query).
However, this is not the same as creating one SQL Statement to insert into multiple tables.
-
 Originally Posted by Phil Weber
I believe you may only INSERT into or UPDATE one table per SQL statement. You may, however, include multiple statements in a single query; separate the statement with a semi-colon.
Thank you so much Phil!
I've never really had experience with SQL databases before and I've been looking for a way to UPDATE multiple tables in one SQL statement without success...
Rather stupid as it sounds, I hadn't thought about just seperating the statement into multiple statements with a semi-colon!
Unfortunately, I seem to have drawn the short-straw on integrating a clients SQL database with our system while our database engineer is AWOL, so this post has pretty much just saved my life!
~ Ray
-
 Originally Posted by Phil Weber
I believe you may only INSERT into or UPDATE one table per SQL statement. You may, however, include multiple statements in a single query; separate the statement with a semi-colon.
Alternately you can place a go inbetween statements. If all transactions must complete before committing you can surround your statements with a begin tran and commit tran or rollback tran if something went wrong.
Similar Threads
-
By dhaya in forum Database
Replies: 11
Last Post: 08-25-2003, 05:24 PM
-
By Gill in forum Database
Replies: 1
Last Post: 08-19-2003, 12:12 PM
-
By Krishna in forum Database
Replies: 1
Last Post: 07-17-2003, 11:36 AM
-
By Bill in forum VB Classic
Replies: 5
Last Post: 10-03-2000, 03:52 PM
-
By VAMM in forum VB Classic
Replies: 2
Last Post: 05-09-2000, 06:03 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|