Question

In: Computer Science

I want to return a query that returns film titles that contain letter 'a' followed by...

I want to return a query that returns film titles that contain letter 'a' followed by repeating characters from the table below.

For example, Married Go (a film in the table) has repeating characters following the letter a.

Table:

CREATE TABLE film_cat_rate (
category character varying(25),
title character varying(255),
rental_rate numeric(4,2)
);


INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('New', 'Amistad Midsummer', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Drama', 'Apollo Teen', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Family', 'Bedazzled Married', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Family', 'Blood Argonauts', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Sports', 'California Birds', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Sci-Fi', 'Camelot Vacation', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Sports', 'Caribbean Liberty', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Animation', 'Champion Flatliners', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Drama', 'Conquerer Nuts', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Documentary', 'Dozen Lion', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Classics', 'Dracula Crystal', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Music', 'Elf Murder', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Foreign', 'Fiction Christmas', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Animation', 'Fight Jawbreaker', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Comedy', 'Freedom Cleopatra', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Travel', 'Games Bowfinger', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Foreign', 'Gentlemen Stage', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Action', 'Gosford Donnie', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Games', 'Grinch Massage', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Action', 'Handicap Boondock', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Documentary', 'Hardly Robbers', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Foreign', 'Hoosiers Birdcage', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Documentary', 'Hunter Alter', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Documentary', 'Independence Hotel', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Travel', 'Italian African', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Classics', 'Jerk Paycheck', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Children', 'Jumping Wrath', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Classics', 'League Hellfighters', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Foreign', 'Lost Bird', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Sci-Fi', 'Married Go', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Action', 'Midnight Westward', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Horror', 'Motions Details', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Family', 'Music Boondock', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Documentary', 'North Tequila', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Animation', 'Oz Liaisons', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Games', 'Panky Submarine', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Foreign', 'Pearl Destiny', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Games', 'Private Drop', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Action', 'Quest Mussolini', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Children', 'Sabrina Midnight', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('New', 'Salute Apollo', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Sports', 'Saturday Lambs', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Children', 'Scarface Bang', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Drama', 'Something Duck', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Travel', 'Tomatoes Hellfighters', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Foreign', 'Town Ark', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Children', 'Uptown Young', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Sci-Fi', 'Vacation Boondock', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Foreign', 'Vision Torque', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Animation', 'Wait Cider', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Drama', 'Wardrobe Phantom', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Sci-Fi', 'Weekend Personal', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Foreign', 'Whale Bikini', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Documentary', 'Wife Turn', 4.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Family', 'Willow Tracy', 2.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Comedy', 'Wisdom Worker', 0.99);
INSERT INTO film_cat_rate (category, title, rental_rate) VALUES ('Music', 'Won Dares', 2.99);

Below is what I have, but I am returning no output. I am using postgres.

select regexp_matches(title, '.{2,}+')
from film_cat_rate
where title like '%a%';

Solutions

Expert Solution

There is no any need of regexp_matches(title, '.{2,}+') to print title contain letter 'a' followed by repeating characters. It only done by  like '%a%'.

Only LIKE operator can perform this, there is no any need of regex.

Thus, below query returns all the title containing letter 'a' followed by repeating characters.

SELECT title FROM film_cat_rate
WHERE title LIKE '%a%';

Output of above query :

NOTE : I used SSMS to run the query


Related Solutions

I want letter about appreciation?
I want letter about appreciation?
I have n books with n different titles. I want to put them on the shelves...
I have n books with n different titles. I want to put them on the shelves in my library. How many different ways are there to arrange them on one shelf? On two shelves? On k shelves?
I want letter about appreciation,to appreciate agency give me scholarship . please I want typing because...
I want letter about appreciation,to appreciate agency give me scholarship . please I want typing because I don't understand handwriting thanks
I want to know why I can not get N(should contain 1000 number) N<-vector() for (k...
I want to know why I can not get N(should contain 1000 number) N<-vector() for (k in 0:999){ y=vector() for(i in 0:999){ r1=runif(1) r2=runif(1) x1=-log(r1) x2=-log(r2) k=(x1-1)^2/2 if (x2 >= k){ r<-runif(1) if (r>0.5){ y[i]= x1 }else{ y[i]= -x1 } } y.1<- y[-which(is.na(y))] number<-length(y.1) } N[k]<-number } N
I want a project report about Rate of Return Analysis with references please. - Introduction -...
I want a project report about Rate of Return Analysis with references please. - Introduction - importance of rate of return to stakeholders ​​​​​​​- Benefits of rate of return - analysis of rate of return - examples - application of rate of return - conclusion
How to calculate Return on Equity?(I just want to learn the formula, no specific data) If...
How to calculate Return on Equity?(I just want to learn the formula, no specific data) If the return on equity is low, how can it be improved? Net Earnings per share Retained earnings, beginning of the year Dividends paid Selling and Admin Expense Operating Profit Interest Expense Income Taxes Net Earnings Retained earnings, end of year Net Sales Cost of goods sold Other income (expense), net Earnings before income taxes
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT