?
Solved

Nested Insert mysql query

Posted on 2009-02-23
3
Medium Priority
?
1,386 Views
Last Modified: 2012-05-06
Hi Experts

How do you do a nested insert query.

My insert query is

INSERT INTO table_name

(table_name.Town,
table_name.County,
table_name.Country,
table_name.PostCode)
VALUES
(... nested select statement)

This is the nested mysql query

SELECT
pafdata.Town,
pafdata.County,
pafdata.Country,
pafdata.PostCode
FROM
pafdata
WHERE
pafdata.Country = 'England'
ORDER BY
pafdata.County ASC
0
Comment
Question by:matthewdacruz
3 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 1000 total points
ID: 23710819
INSERT INTO table_name

(table_name.Town,
table_name.County,
table_name.Country,
table_name.PostCode)
SELECT
pafdata.Town,
pafdata.County,
pafdata.Country,
pafdata.PostCode
FROM
pafdata
WHERE
pafdata.Country = 'England'
0
 
LVL 11

Assisted Solution

by:Otana
Otana earned 1000 total points
ID: 23710827
Try this (you may have to remove the ORDER BY part):
INSERT INTO table_name
(table_name.Town,
table_name.County,
table_name.Country,
table_name.PostCode)
SELECT
pafdata.Town,
pafdata.County,
pafdata.Country,
pafdata.PostCode
FROM
pafdata
WHERE
pafdata.Country = 'England'
ORDER BY
pafdata.County ASC
0
 

Author Closing Comment

by:matthewdacruz
ID: 31550063
Thanks guys, that did the trick. i shared the points as both worked for me
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

621 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