Home > Back-end >  Consult: adoquery multi-table query, single table updates
Consult: adoquery multi-table query, single table updates

Time:09-30

Three tables, A, B, C, A query is to use the SELECT A.A 1, A.A 2, 3, A.A B.B 1, 2, B.B B.B 3, Arthur c. 2 FROM A INNER JOIN ON A.A 1 B=B.B 1
INNER JOIN B.B 2=1 WHERE Arthur c. A.A 1='conditions', but I update just update A table, not to update, table B, C table, use ADOQUERY consult everybody, how to solve, thank you very much,

CodePudding user response:

In a Query control, combined the results of the Query data set is read-only, you can't use the Query, Edit update,
Want to update, only to write a SQL statement,

CodePudding user response:

Update statement updated can only guarantee, their execution

CodePudding user response:

SELECT A.A 1, A.A 2, 3, A.A (1 from the SELECT B.B B where B.B 1=1) A.A as B1, (from the SELECT B.B 2 B where B.B 1=1) A.A as B2 from A
So A Query can be used to update A field
If don't think writing concise consider function is used to implement the specific writing according to the different database is slightly different
Form the following
SELECT 1, A.A A.A 2, 3, A.A getB1 (A1) as B1, getB2 (A1) as B2 FROM A

CodePudding user response:

Only if the update of fields in A table, and A table has A primary key, there is A strong possibility that can be updated,

CodePudding user response:

If the BDE, UpdateSQL easily calm, with a
ADO is not so simple, however,
ADO joint query (table) specified update methods:
1: use a separate SQL statements to update (other methods are the use of this method),
2: between ADO component and a DataSource component extensions,
Method 1 (with built-in component, when it was released to join Midaslib unit) : TADOQuery + TDataSetProvider + the TClientDataSet + TDataSource;
Key: 1 TDataSetProvider onGetTableName event set to update the table name, TableName='XXX';
2 double-click the TADOQuery set ProviderFlags properties of each field,

Method 2 (use EHlib components, powerful, but slow) : TADOQuery + TADODataDriverEh + TMemTableEh + TDataSource;
The more similar the BDE UpdateSql function, double-click TADODataDriverEh set is ok,

CodePudding user response:

May and by way of clientdataset and datasetprovider configuration update queries down the field type is the key field, whether to update the table fields

CodePudding user response:

The system will automatically update, do not need to write SQL code,

CodePudding user response:

A table, a query can, of course, after the datasource with different query

CodePudding user response:

When you need to update and this is ok,
Adoquery1. Requery ()

CodePudding user response:

refer to the original poster SXZZ94342 response:
there are three tables, A, B, C, A query is to use the SELECT A.A 1, A.A 2, 3, A.A B.B 1, 2, B.B B.B 3, Arthur c. 2 FROM A INNER JOIN ON A.A 1 B=B.B 1
INNER JOIN B.B 2=1 WHERE Arthur c. A.A 1='conditions', but I update just update A table, not to update, table B, C table, use ADOQUERY consult everybody, how to solve, thank you very much.


To use a ADOQuery to specify the data updated

CodePudding user response:

The question I asked before, let's write SQL statements to update
  • Related