Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
281 views
in Technique[技术] by (71.8m points)

mysql - MySQL多表查询(MySQL Multiple Table Query)

The question with criteria

(有标准的问题)

Any help with creating the SELECT statement that satisfies this criteria would be appreciated.

(创建满足此条件的SELECT语句的任何帮助将不胜感激。)

The tables I believe are being use are as follows.

(我认为正在使用的表格如下。)

CREATE TABLE client ( ClientID varchar(7) NOT NULL, ClientName varchar(45) DEFAULT NULL, Street varchar(100) DEFAULT NULL, City varchar(45) DEFAULT NULL, State char(2) DEFAULT NULL, Zip char(5) DEFAULT NULL, PRIMARY KEY ( ClientID ) )

(创建表clientClientID varchar(7)NOT NULL, ClientName varchar(45)DEFAULT NULL, Street varchar(100)DEFAULT NULL, City varchar(45)DEFAULT NULL, State char(2)DEFAULT NULL, Zip char(5)DEFAULT NULL,PRIMARY KEY( ClientID )))

CREATE TABLE contact ( ClientID varchar(7) NOT NULL, ContactName varchar(45) NOT NULL, ContactPhone char(17) DEFAULT NULL, ContactEmail varchar(45) DEFAULT NULL, PRIMARY KEY ( ClientID , ContactName ), CONSTRAINT FK_ClientContact FOREIGN KEY ( ClientID ) REFERENCES client ( ClientID ) )

(CREATE TABLE contactClientID varchar(7)NOT NULL, ContactName varchar(45)NOT NULL, ContactPhone char(17)DEFAULT NULL, ContactEmail varchar(45)DEFAULT NULL,PRIMARY KEY( ClientIDContactName ),CONSTRAINT FK_ClientContact FOREIGN KEY( ClientID )参考clientClientID )))

Here is what I've got so far.

(这是我到目前为止所得到的。)

SELECT ClientName, contact.ContactName, ContactPhone, ContactEmail, count() FROM client, contact GROUP BY ClientName, ContactName, ContactPhone, ContactEmail ORDER BY ClientName;

(选择ClientName,contact.ContactName,ContactPhone,ContactEmail,count()从客户端,GROUP BY ClientName,ContactName,ContactPhone,ContactEmail OR BY BY ClientName;)

  ask by Bellaboof translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...