MySQL CONCAT and AS Example

MySQL CONCAT and AS Example


Simple example to show how to use CONCAT (concatenate), to join to parts of the table together and name the query.

SELECT CONCAT (tile," ",quantity) 
AS stock
FROM products;



OUTPUT

+------------+
| stock           |
+------------+
| Shoes 200    |
| Soap 2003   |
| Shampoo 34 |
| DVD 23       |
| CD 34          |
+------------+

By choosing the columns tile and quantity and using the CONCAT and AS functions, we can have a single column called stock that shows the title of the product and the quantity left in stock.


MYSQL EXAMPLE OF CONCAT and AS



No comments:

Post a Comment