SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Query - Insert to two tables with select
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kwst83
Starting Member

Greece
2 Posts

Posted - 10/30/2013 :  07:57:38  Show Profile  Reply with Quote
Hello,

maybe this question is being asked again in the past, but i cannot find any solution on the web.

I have those 3 tables (sales,source, sales, sales_details),


Sales_source (table)
id, name

1 Office
2 Post
3 Web

Sales (table)
id, saleid, customer, source, date

01, 230, bill din, 1, 2013-10-22


Sales_details (table)
id, saleid, object, delivery, date

01, 230, card, no, 2013-10-23
02, 230, box, yes, 2013-10-24
03, 230, car, no, 2013-10-31


and i want to create if is possible one insert command

and make the user complete the details of Sales_details (that they have inner join for the sales_source table so he can see only the sales_source_name and behind the sales_source_id to be stored)

and after to be able to add in as many [sale_details] he need for the select sale…

is this possible to be done with one command ???

i think is not possible as i have made a small research on the web, and i will need to make one insert for the sales (table) independent and after to programming i guess a way to open the sale_details and add the rest….

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/30/2013 :  08:21:21  Show Profile  Reply with Quote
sorry your question doesnt make much sense to me.
Are you asking for a insert procedure to create sales data on all the above tables with proper relationships?
also this part
and after to be able to add in as many [sale_details] he need for the select sale…
where will he select sale from? do you've a page where you display this details?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

kwst83
Starting Member

Greece
2 Posts

Posted - 10/30/2013 :  08:29:57  Show Profile  Reply with Quote
well the thing is that i am trying to make this in SqlMaestro Php generator application,

i don't know if you have ever experience this app.

But it let you make any solo insert / update and select for a table but to make something like this you need to add it like a query.

So basically i am able to add a an Insert so i can add a record to the Sales table with the inner join of the Sales_Source (so they can select the source by name and not by the id) without a problem.

But I would like to be able to make it all at one.

Meaning... that I need to make it in one action (so not trouble my users with many different insert dialogs) ... and do what ...

To be able to add a normal record for the Table Sales (with the inner join of the Sales_source) and underneath to be able to add the details of this sales to the other table direct (as many they are, minimum more than one), so I was thinking that if is possible to create a query that does this in one time maybe the application leave me do it in one screen, without force the users to add first the head sale and after go to put the sales details in a different screen...maybe i more details now ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 10/30/2013 :  08:43:38  Show Profile  Reply with Quote
This is not a SqlMaestro Php generator application related forum.
This is MS SQL Server forum and we deal with only Transact SQL related queries. So you may be better off posting this in relevant forums.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.38 seconds. Powered By: Snitz Forums 2000