Solved

insert into while selecting from another table MySQL

Posted on 2014-12-03
3
538 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now