w3resource

AdventureWorks Database: Product with prefixes of either chain or full

SQL Query - AdventureWorks: Exercise-57 with Solution

57. From the following table write a query in SQL to return all category descriptions containing strings with prefixes of either chain or full.

Sample table: Production.Product


Click to view Full table

Sample Solution:

SELECT Name, color  
FROM Production.Product  
WHERE to_tsvector(name) @@ to_tsquery('"chain*" | "full*"');

Sample Output:

name                 |color |
---------------------+------+
Chain Stays          |      |
Full-Finger Gloves, S|Black |
Full-Finger Gloves, M|Black |
Full-Finger Gloves, L|Black |
Chain                |Silver|

SQL AdventureWorks Editor:

Practice Online


Contribute your code and comments through Disqus.

Previous: Product names that begin with the prefix chain.
Next: Employee name, email separated by a new line.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Share this Tutorial / Exercise on : Facebook and Twitter

SQL: Tips of the Day

How to create a foreign key in SQL Server?

create table question_bank
(
    question_id uniqueidentifier primary key,
    question_exam_id uniqueidentifier not null,
    question_text varchar(1024) not null,
    question_point_value decimal,
    constraint fk_questionbank_exams foreign key (question_exam_id) references exams (exam_id)
);

Database: SQL Server

Ref : https://bit.ly/3sgS152