Solved

insert into while selecting from another table MySQL

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

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!
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…

776 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