• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1392
  • Last Modified:

Nested Insert mysql query

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
matthewdacruz
Asked:
matthewdacruz
2 Solutions
 
momi_sabagCommented:
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
 
OtanaCommented:
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
 
matthewdacruzAuthor Commented:
Thanks guys, that did the trick. i shared the points as both worked for me
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now