Mysql multi-value query _ MySQL

Source: Internet
Author: User
Mysql multi-value query requirements: query the title of all articles that contain both aa and cc.

Query SQL: SELECT kk. 'title', COUNT (1) times FROM (SELECT 'title', 'content' FROM 'article' WHERE 'content' IN ('AA', 'CC ') group by 'title', 'Content') kk group by kk. 'title' HAVING times> = 2; create table if not exists 'article' ('id' int (11) not null AUTO_INCREMENT, 'title' varchar (100) not null, 'content' varchar (20) not null, primary key ('id') ENGINE = InnoDB default charset = utf8 AUTO_INCREMENT = 5; insert into 'article' ('id ', 'title', 'Content') VALUES (1, 'A', 'A'), (2, 'A', 'CC'), (3, 'A ', 'A'), (4, 'C', 'CC ');


The effect is estimated to be poor. please point it to me

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.