Changing SQL column header with query

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 can I change the title for product_option_value_description.name since I would like to name this option.

+7
source share
4 answers

Use an alias, for example:

 product_option_value_description.name AS `Option` 

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

 ALTER TABLE product_option_value_description CHANGE name newname DATATYPE; 
+16
source

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 
+7
source

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

+6
source

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

+1
source

All Articles