Click here to Skip to main content
15,904,822 members
Home / Discussions / Database
   

Database

 
GeneralCopy rows from one table from another Pin
Luis Alonso Ramos29-Nov-04 9:23
Luis Alonso Ramos29-Nov-04 9:23 
GeneralRe: Copy rows from one table from another Pin
Edbert P29-Nov-04 10:56
Edbert P29-Nov-04 10:56 
GeneralRe: Copy rows from one table from another Pin
Luis Alonso Ramos29-Nov-04 11:22
Luis Alonso Ramos29-Nov-04 11:22 
Thanks for your reply.

I use SELECT to get the quote info (customer information and employee) into local variables and then I insert those into my Orders table.

My QuoteItems table has several fields (ID_item (identity PK), ID_quote, Description) and my Items table has those fields plus others (ID_item (identity PK, different from QuoteItems'), ID_order (newly created order), Description, Produced (must be set to false on record insertion)).

I can create the new Orders record based on my Quotes record. Then I need to select all records from QuoteItems with a specific ID_quote and insert corresponing records into the Items table, copying some fields, and setting others to an arbitrary value (like the ID_order field).

I remember seeing a query like this:
UPDATE Items SET Field=value WHERE id_item IN (SELECT id_item FROM Orders WHERE ID_order=1);
I don't know the exact syntax, and whether I could apply it here, but I would believe my answer would somewhere close to that.

I hope I have explained myself better. Thanks for your help,

-- LuisR




Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!

GeneralRe: Copy rows from one table from another Pin
Luis Alonso Ramos30-Nov-04 8:14
Luis Alonso Ramos30-Nov-04 8:14 
GeneralRe: Copy rows from one table from another Pin
Edbert P30-Nov-04 10:49
Edbert P30-Nov-04 10:49 
GeneralRe: Copy rows from one table from another Pin
Luis Alonso Ramos30-Nov-04 13:25
Luis Alonso Ramos30-Nov-04 13:25 
GeneralRe: Copy rows from one table from another Pin
Edbert P30-Nov-04 15:11
Edbert P30-Nov-04 15:11 
GeneralRe: Copy rows from one table from another Pin
Luis Alonso Ramos30-Nov-04 15:23
Luis Alonso Ramos30-Nov-04 15:23 
GeneralSQL statement help Pin
ruifernandes2429-Nov-04 7:29
ruifernandes2429-Nov-04 7:29 
GeneralRe: SQL statement help Pin
Gerald Schwab29-Nov-04 7:58
Gerald Schwab29-Nov-04 7:58 
GeneralDataSet 2 Xml - element order problem Pin
Xabatcha29-Nov-04 3:18
Xabatcha29-Nov-04 3:18 
QuestionOREIGN KEY REFERENCES? Pin
HahnTech28-Nov-04 12:42
HahnTech28-Nov-04 12:42 
AnswerRe: OREIGN KEY REFERENCES? Pin
Christian Graus28-Nov-04 13:46
protectorChristian Graus28-Nov-04 13:46 
GeneralRe: OREIGN KEY REFERENCES? Pin
HahnTech28-Nov-04 14:54
HahnTech28-Nov-04 14:54 
GeneralRe: OREIGN KEY REFERENCES? Pin
Christian Graus28-Nov-04 18:13
protectorChristian Graus28-Nov-04 18:13 
GeneralRe: OREIGN KEY REFERENCES? Pin
Edbert P28-Nov-04 18:44
Edbert P28-Nov-04 18:44 
GeneralRe: OREIGN KEY REFERENCES? Pin
HahnTech28-Nov-04 23:23
HahnTech28-Nov-04 23:23 
AnswerRe: OREIGN KEY REFERENCES? Pin
Mike Dimmick29-Nov-04 1:00
Mike Dimmick29-Nov-04 1:00 
GeneralRe: OREIGN KEY REFERENCES? Pin
HahnTech29-Nov-04 12:00
HahnTech29-Nov-04 12:00 
AnswerRe: OREIGN KEY REFERENCES? Pin
Chris Meech29-Nov-04 7:16
Chris Meech29-Nov-04 7:16 
GeneralUpdate Statement Pin
jlawren728-Nov-04 12:28
jlawren728-Nov-04 12:28 
GeneralRe: Update Statement Pin
Christian Graus28-Nov-04 13:48
protectorChristian Graus28-Nov-04 13:48 
GeneralRe: Update Statement Pin
Edbert P28-Nov-04 18:39
Edbert P28-Nov-04 18:39 
GeneralRe: Update Statement Pin
jlawren729-Nov-04 1:39
jlawren729-Nov-04 1:39 
GeneralRe: Update Statement Pin
Luis Alonso Ramos29-Nov-04 10:03
Luis Alonso Ramos29-Nov-04 10:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.