0% found this document useful (0 votes)
4 views1 page

Day 21 SQL String Functions (1)

The document contains a series of SQL queries for manipulating and retrieving data from a 'products' table. It includes commands to select all products, format category names, concatenate product details, extract substrings, count character lengths, trim whitespace, and replace specific words in product names. Additionally, it retrieves the last three characters from category names.

Uploaded by

thombreb956
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Day 21 SQL String Functions (1)

The document contains a series of SQL queries for manipulating and retrieving data from a 'products' table. It includes commands to select all products, format category names, concatenate product details, extract substrings, count character lengths, trim whitespace, and replace specific words in product names. Additionally, it retrieves the last three characters from category names.

Uploaded by

thombreb956
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

SELECT * from products;

-- Get all the categories in Uppercase

SELECT UPPER(category) AS Catergory_Capital


FROM products;

-- Get all the categories in Lowercase

SELECT LOWER(category) AS Catergory_Capital


FROM products;

-- Join Product_name adn category text with hypen.


SELECT CONCAT(product_name,'-',category) As product_details
FROM products;

-- Extract the first 5 characters from product_name


SELECT SUBSTRING(product_name, 1,5) AS short_name
FROM products;

-- Count length
SELECT product_name, LENGTH(product_name) AS COUNT_OF_CHAR
FROM products;

--Remove leading and trailing spaces from string


SELECT LENGTH(TRIM(' Monitor ')) AS Trimmed_Text;
SELECT LENGTH(' Monitor ') AS Trimmed_Text;

-- Replace the word "phone" with "device" in product names


SELECT REPLACE(product_name, 'phone','device') AS updated
FROM products;

-- Get the first 3 characters from category

SELECT RIGHT(category, 3) AS Catergory_Capital


FROM products;

You might also like