通过查询更改SQL列标题

时间:2021-12-24 10:39:09

I have the following query:

我有以下查询:

SELECT product_description.name, product.quantity,product.price,product_option_value_description.name,product_option_value.quantity
FROM product
INNER JOIN product_description
ON product.product_id=product_description.product_id
INNER JOIN product_option_value_description
ON product.product_id=product_option_value_description.product_id
INNER JOIN product_option_value
ON product.product_id=product_option_value.product_id
ORDER BY product_description.name 

How could I change the title for product_option_value_description.name as I would like to name this option.

我怎么能改变product_option_value_description.name的标题,因为我想命名这个选项。

4 个解决方案

#1


18  

Use an alias like so:

使用如下别名:

product_option_value_description.name AS `Option`

If you want to change the column's name, not only for this query but in general use ALTER TABLE

如果要更改列的名称,不仅要更改此查询,还要更改ALTER TABLE

ALTER TABLE product_option_value_description CHANGE name newname DATATYPE;

#2


7  

Use as

For example:

SELECT product_description.name as 'ProdName', product.quantity,product.price,product_option_value_description.name as 'ProdDesc',product_option_value.quantity FROM product

#3


6  

Just write product_option_value_description.name AS Name to create the alias "Name" for this column.

只需编写product_option_value_description.name AS Name即可为此列创建别名“Name”。

#4


1  

You can use any alias name using the 'AS' keyword. eg. select student_id AS id from student_info

您可以使用'AS'关键字来使用任何别名。例如。从student_info中选择student_id AS id

#1


18  

Use an alias like so:

使用如下别名:

product_option_value_description.name AS `Option`

If you want to change the column's name, not only for this query but in general use ALTER TABLE

如果要更改列的名称,不仅要更改此查询,还要更改ALTER TABLE

ALTER TABLE product_option_value_description CHANGE name newname DATATYPE;

#2


7  

Use as

For example:

SELECT product_description.name as 'ProdName', product.quantity,product.price,product_option_value_description.name as 'ProdDesc',product_option_value.quantity FROM product

#3


6  

Just write product_option_value_description.name AS Name to create the alias "Name" for this column.

只需编写product_option_value_description.name AS Name即可为此列创建别名“Name”。

#4


1  

You can use any alias name using the 'AS' keyword. eg. select student_id AS id from student_info

您可以使用'AS'关键字来使用任何别名。例如。从student_info中选择student_id AS id