Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
280 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 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...