Quote:
I'm not well understood some expression.
E.G.
{expr1|DEFAULT}
where_condition
table_references
etc.
Are there example links? TIA
|
That, I can understand, let take an example:
Quote:
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
|
For the conventions, in almost every programming doc I have seen, what is contained between [ and ] is optionnal.
What is contained bewteen { and } denote that you have a choice, and each choices is delimited by |
Something like
Code:
[, col_name2={expr2|DEFAULT}] ...
should be read "separate each column to be updated by a comma, and add as much as you need to the query".
As they are between [], it means that it's not mandatory, which is logical.
The WHERE clause is the filter. It's where you will tell to the sql engine what conditions should the rows have to be elected to be updated.
And the LIMIT statement is pretty self explanatory, it allows you to apply that update to the x first elements only.
That one is generally used with the ORDER BY statement, to ensure that the order of the rows is known.
Otherwise, you cannot be assured of the rows order.
So, in this example, it means that the smallest query that you can write is
Code:
UPDATE tbl_name
SET col_name1=value1
But you could end up with
Code:
UPDATE LOW_PRIORITY tbl_name
SET col_name1=value1, col_name2=value2, col_name3=value3, col_name4=value4, col_name5=DEFAULT, col_name6=value7
WHERE enabled=1
AND creation_date between '2006-01-01' and '2006-03-01'
AND EXISTS (
SELECT 1
FROM other_table
WHERE id=tbl_name.id
AND status='paid'
)
Which, will being more complex, is still pretty understandable, I think.