SQL -vs- PYTHON
So, SQL IS NOT LIKE PYTHON
READING THE CODE ONE BY ONE (ROW BY ROW) ---> Python
CUZ WE USED ORDER BY
BEFORE ADDING THE VALUES IN THE INSERT
FUNCTION
Hi Peter!
Thanks for reaching out.
Yes, there is a difference between both languages.
The actual execution of MySQL statements is a bit tricky. However, the standard does specify the order of interpretation of elements in the query. The order is the following:
FROM clause
WHERE clause
SELECT clause
GROUP BY clause
HAVING clause
ORDER BY clause
This is important for understanding how queries are parsed. You cannot use a column alias defined in a SELECT in the WHERE clause, for instance, because the WHERE is parsed before the SELECT. On the other hand, such an alias can be in the ORDER BY clause.
Hope this helps.
Best,
Tsvetelin