Solved

insert into while selecting from another table MySQL

Posted on 2014-12-03
3
558 Views
Last Modified: 2014-12-03
I want to insert into Inventory_Parts and select some of the values from  Inventory_InventoryList table and I want to do it for every item in the Inventory_InventoryList table...... how do I do it?



INSERT INTO `Inventory_Parts`(`UID`, `LocationID`, `Quantity`, `Desc`, `Notes`, `ConditionID`, `InventoryListID`) VALUES (0,0,25,desc,'',1,listid)

select UID as 'listid',Desc as 'desc' FROM Inventory_InventoryList

Open in new window

0
Comment
Question by:r3nder
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
Ahmed Merghani earned 500 total points
ID: 40479279
Try this:
INSERT INTO `Inventory_Parts`(`UID`, `LocationID`, `Quantity`, `Desc`, `Notes`, `ConditionID`, `InventoryListID`) 
select 0,0,25, Desc ,'', 1, UID  FROM Inventory_InventoryList

Open in new window

0
 
LVL 6

Author Closing Comment

by:r3nder
ID: 40479405
Thank you Ahmed! worked perfect
0
 
LVL 8

Expert Comment

by:Ahmed Merghani
ID: 40480128
You are welcome.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Using cfstoredproc to return query data 2 30
query question 12 32
Access join syntax when converting to T-SQL query 4 32
Exchange 2013 weird behavior 6 27
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question