SQL——c.column name AS new columnname是什么意思?


c.[columnname] AS [NEWcolumnname]
在SQL中,c是什么意思?

在这种情况下,c只是某人分配的别名。这个c来自sql查询中的某个地方,就在from或Join或列名之后。括号大多是可选的,在大多数情况下你不是绝对需要它们

这里有一个关于别名的好例子

select m.foodtype as f
from menu as m
left join ingredient as i
on i.type = m.type

这些别名是在编写sql查询时创建和分配的。

对于这个例子,如果你这样命名它也是可以的:

select mymenu.foodtype as RecipeType1
from menu as mymenu
left join ingredient as ingredients
on ingredients.type = mymenu.type