Meaning of an access Query

  • Thread starter Thread starter Security
  • Start date Start date
S

Security

I would like to know the meaning of this query
INSERT INTO [TABLE1] ( codcli, [flag griffe], qte, [qte griffe] )
SELECT [TABLE1].codcli, [TABLE1].[flag griffe], Sum([TABLE1].qte) AS
SommeDeqte, Sum([qte])+0 AS Expr1
FROM [TABLE1] GROUP BY [TABLE1].codcli, [TABLE1].[flag griffe]

I don't understand the meaning of the syntax : INSERT INTO ... SELECT ...
FROM ?

Second question : does an 'IF' be as part of an SQL request : If ... Then
....

thank you
 
Security said:
I would like to know the meaning of this query
INSERT INTO [TABLE1] ( codcli, [flag griffe], qte, [qte griffe] )
SELECT [TABLE1].codcli, [TABLE1].[flag griffe], Sum([TABLE1].qte) AS
SommeDeqte, Sum([qte])+0 AS Expr1
FROM [TABLE1] GROUP BY [TABLE1].codcli, [TABLE1].[flag griffe]

I don't understand the meaning of the syntax : INSERT INTO ... SELECT ...
FROM ?

Essentially the query SELECTS records FROM one table and INSERTS them INTO a
different one. It's called an Append Query.
Second question : does an 'IF' be as part of an SQL request : If ... Then

In Access SQL you would use the Immediate-If function IIf(Test, ReturnForTrue,
ReturnForFalse) or the Switch() function, or a UserDefined function. In a
Pass-Through query against most server databases you would use a CASE statement.
 
Would you have an exemple of an access query using the IF funtion ?



Rick Brandt said:
Security said:
I would like to know the meaning of this query
INSERT INTO [TABLE1] ( codcli, [flag griffe], qte, [qte griffe] )
SELECT [TABLE1].codcli, [TABLE1].[flag griffe], Sum([TABLE1].qte) AS
SommeDeqte, Sum([qte])+0 AS Expr1
FROM [TABLE1] GROUP BY [TABLE1].codcli, [TABLE1].[flag griffe]

I don't understand the meaning of the syntax : INSERT INTO ... SELECT ....
FROM ?

Essentially the query SELECTS records FROM one table and INSERTS them INTO a
different one. It's called an Append Query.
Second question : does an 'IF' be as part of an SQL request : If ...
Then

In Access SQL you would use the Immediate-If function IIf(Test, ReturnForTrue,
ReturnForFalse) or the Switch() function, or a UserDefined function. In a
Pass-Through query against most server databases you would use a CASE statement.
 
Security said:
Would you have an exemple of an access query using the IF funtion ?

A common usage is to avoid divide by zero errors. The following replaces what
would otherwise be a DBZ error with the string "N/A"

SELECT IIf([DivisorField] = 0, "N/A", [DividendField]/[DivisorField]) AS
Percentage
FROM SomeTable
 
Back
Top