Einzelnen Beitrag anzeigen

Benutzerbild von baumina
baumina

Registriert seit: 5. Mai 2008
Ort: Oberschwaben
1.275 Beiträge
 
Delphi 11 Alexandria
 
#3

AW: UniDac: Datensatz kopieren

  Alt 14. Mai 2013, 13:03
Ich habe gelesen, dass SQLite Subqueries in Klammern braucht, deswegen versuchs mal so:

Code:
INSERT INTO tabA (SELECT * FROM tabB WHERE id = 'xyz')
EDIT : Nein, stimmt nicht im Handbuch von SQLite stehts genau so wie du es hattest
Zitat:
Subqueries with the INSERT Statement:

Subqueries also can be used with INSERT statements. The INSERT statement uses the data returned from the subquery to insert into another table. The selected data in the subquery can be modified with any of the character, date, or number functions.

The basic syntax is as follows:
INSERT INTO table_name [ (column1 [, column2 ]) ]
SELECT [ *|column1 [, column2 ]
FROM table1 [, table2 ]
[ WHERE VALUE OPERATOR ]

Example:

Consider a table COMPANY_BKP with similar structure as COMPANY table and can be created using same CREATE TABLE using COMPANY_BKP as table name. Now to copy complete COMPANY table into COMPANY_BKP, following is the syntax:
sqlite> INSERT INTO COMPANY_BKP
SELECT * FROM COMPANY
WHERE ID IN (SELECT ID
FROM COMPANY) ;
Also eine TUniQuery nehmen, SQL einfügen und via ExecSQL ausführen, fertig.

Geändert von baumina (14. Mai 2013 um 13:23 Uhr)
  Mit Zitat antworten Zitat