In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "the usage of join, left join and right join in mysql". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
For the time being, we will demonstrate with two tables:
Create the bro_ cats table:
Create table bro_cats (
Id int (11) not null auto_increment
Name varchar (128) not null default'
Desn varchar (128) not null default'
Primary key ()
);
Create the bro_ artifacts table:
Create table bro_articles (
Id int not null auto_increment
Cid int not null
Name varchar (128) not null
Content test not null
Primary key (id)
);
Next, we insert data into it.
INSERT INTO bro_cats (name, desn) values ('php','php demo')
INSERT INTO bro_cats (name, desn) values ('jsp','jsp demo')
INSERT INTO bro_cats (name, desn) values ('', 'asp demo')
Cid=1 in INSERT INTO bro_articles (cid, name, content) / / php class
Values (1) this article of php1', 'php content1')
Cid=1 in INSERT INTO bro_articles (cid, name, content) / / php class
Values (1) this article of php2', 'php content2')
INSERT INTO bro_articles (cid, name, content) / / cid=2 in class
Values (2) this article of jsp', 'jsp content')
Cid=3 in INSERT INTO bro_articles (cid, name, content) / / asp class
Values (3 million this article of asp1', 'asp content1')
Cid=3 in INSERT INTO bro_articles (cid, name, content) / / asp class
Values (3 million this article of asp2', 'asp content2')
Next, let's test it with the join statement.
Left join: left join
Select bro_cats.name as catsname,bro_cats.desn as description,bro_articles.name as articlesname,bro_articles.content as articlecontent from bro_cats left join bro_articles on bro_cats.id = bro_articles.cid
Right connection: right join
Select bro_cats.name as catsname,bro_cats.desn as description,bro_articles.name as articlesname,bro_articles.content as articlecontent from bro_cats right join bro_articles on bro_cats.id = bro_articles.cid
Connection: join
Select bro_cats.name as catsname,bro_cats.desn as description,bro_articles.name as articlesname,bro_articles.content as articlecontent from bro_cats join bro_articles on bro_cats.id = bro_articles.cid
What are the specific effects of these three? I suggest you try and compare yourself to come to a conclusion.
This is the end of the introduction to "the use of join, left join and right join in mysql". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.