The columns produced by your query can have different names than their actual names. This aliasing can be easily achieved with the AS keyword.
i.e.
SELECT
"product_name"
, "countries" AS "nations"
FROM openfoodfacts_data
The columns output by this query would be “product_name” and “nations”
Never use a field’s alias in the query, in which you created the alias.
i.e.
SELECT
"product_name"
, "countries" AS "nations"
FROM openfoodfacts_data
WHERE “countries” = “United States”
Here “countries” was and should be used in the WHERE statement not “nations”
You can alias table names.
i.e.
SELECT
"product_name"
, "countries" AS "nations"
FROM openfoodfacts_data AS off_data
In contrast to field aliases, table aliases can be used in the WHERE statement of the query they were created in.
i.e.
SELECT
"product_name"
, "countries" AS "nations"
FROM openfoodfacts_data AS off_data
WHERE off_data.countries = “United States”
#sql #alias #databases