Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting records from another table 1

Status
Not open for further replies.

pingLeeQuan

Programmer
Joined
Jul 3, 2002
Messages
45
Location
US
Hello, i am using the following SQL to insert records into Summary table from another table but i keep getting a syntax error. When i run teh sqls individually, they work ok... any thought on how i can get this done?

INSERT INTO tSummary
(ssnumber,unitid,projectid,tenant_lname,tenant_fname)
VALUES(select ssnumber,unitid,projectid,tenant_lname, tenant_fname from tExternalData)

The error that i get follows:

[admin] ERROR 1064: You have an error in your SQL syntax near 'select ssnumber,unitid,projectid,tenant_lname, tenant_fname from tExternalData)' at line 3

thanks in advance
 
That's because MySQL doesn't support the kind of subquery like you're trying to use until version 4.1.

MySQL has a special syntax for selecting data from one table and inserting it into another table, the INSERT...SELECT query

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
dude... that worked like a charm... thanks a bunch..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top