How to INSERT a SELECT query in MYSQL?
-
INSERT INTO Vendor (VName, VPhone, VLoc) VALUES ('Mike Douglas', '260-555-5555', 'Denver, CO)"; The Vendor table also has a field for CarID. There is a Car Table that has the following row: CarID: 89 | Make: Pontiac | Model: GrandAm | Miles: 87000 | Year: 1999 | Now, for the first INSERT command, how do I add the CarID for the above Car table row only and not all other rows? INSERT INTO Vendor(CarID) SELECT CarID FROM Car WHERE (Car.Miles=87000) and (Car.Year=1999) The above query would take that CarID from that one row in Car table, but how do I combine the two INSERT commands above so that the CarID gets updated in the Vendor table from a specific row in the Car table but also updates the above Vendor information too (Vname, VPhone, VLoc) ?
-
Answer:
Chris S at Yahoo! Answers Visit the source
Related Q & A:
- How to write a complex query with doctrine?Best solution by Stack Overflow
- How to convert a SQL query into hibernate criteria?Best solution by Stack Overflow
- How to insert or select random ID's to CC or BCC, in the New Yahoo mail version?Best solution by Yahoo! Answers
- How to insert a picture into email?Best solution by Yahoo! Answers
- How to insert a date variable in java?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.