Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MySql A column that returns the third word in the product_name in the products table. If there is no third word, it should return an

MySql

A column that returns the third word in the product_name in the products table. If there is no third word, it should return an empty string. You can do this using IF and SUBSTRING_INDEX. Hint, this is complicated, the idea is that you write expression2 using SUBSTRING_INDEX that will return the 1st word if there is only one word, or the 2nd word if there are 2 words. Write expression3 using SUBSTRING_INDEX that will return the 1st word if there is only one word, or the 2nd word if there are 2 words and the 3rd word if there are three words. Then combine expression2 and expression3 with if as follows: IF ( expression2 != expresion3 , expression3, '') AS third_name Order by product_name.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Web Database Development Step By Step

Authors: Jim Buyens

1st Edition

0735609667, 978-0735609662

More Books

Students also viewed these Databases questions