0

我有四张桌子

CREATE TABLE IF NOT EXISTS Englishword (WordId int NOT NULL,WordName varchar(100) NOT NULL,PRIMARY KEY (WordId))

CREATE TABLE IF NOT EXISTS MeaningInAmharicforEnglish (MeaningidA int(11) NOT NULL,WordIdA int NOT NULL,MeaningNameA varchar(50) NOT NULL,WordclassA varchar (50) NOT NULL,PRIMARY KEY (MeaningidA),FOREIGN KEY (WordIdA) REFERENCES Englishword(WordId) ON UPDATE CASCADE ON DELETE CASCADE) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci

CREATE TABLE IF NOT EXISTS MeaningInTigrgnaforEnglish (MeaningidT int(11) NOT NULL,WordIdT int NOT NULL,MeaningNameT varchar(50) NOT NULL,WordclassT varchar (50) NOT NULL,PRIMARY KEY (MeaningidT),FOREIGN KEY (WordIdT) REFERENCES Englishword(WordId) ON UPDATE CASCADE ON DELETE CASCADE) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci

CREATE TABLE IF NOT EXISTS MeaningInEnglishforEnglish (MeaningidE int(11) NOT NULL,WordIdE int NOT NULL,MeaningNameE varchar(100) NOT NULL,WordclassE varchar (50) NOT NULL,PRIMARY KEY (MeaningidE),FOREIGN KEY (WordIdE) REFERENCES Englishword(WordId) ON UPDATE CASCADE ON DELETE CASCADE)

我有一个英文单词的数据

1 去

我在 MeaningInEnglishforEnglish 中有一个数据

1 1 hello 动词
2 1 hello 名词

我在 MeaningInAmharicforEnglish 中有一个数据

1 1 ራቀ 动词
2 1 ራቀ 名词

我在 MeaningInTigrgnaforEnglish 中有一个数据

1 1 ሄደ 动词
2 1 ሄደ 名词

我使用了以下查询

SELECT  WordId,
WordName,WordclassE,MeaningidE,MeaningNameE,WordclassA,MeaningidA,MeaningNameA,WordclassT,MeaningidT,MeaningNameT

FROM Englishword AS E, MeaningInEnglishforEnglish AS EM, MeaningInAmharicforEnglish AS AE, MeaningInTigrgnaforEnglish AS TE

WHERE (E.WordId = EM.WordIdE)
AND (E.WordId = AE.WordIdA)
AND (E.WordId = TE.WordIdT)

这给了我以下结果:

 WordId     WordName  WordclassE  MeaningidE  MeaningNameE  WordclassA  MeaningidA   
 1              go      verb       1            hello         verb     1   
 1              go      verb      1             hello         verb         1 
 1              go      verb      1             hello         verb         1
 1              go      verb      1             hello         verb         1
 1              go      verb      2             hello         verb         2 
 1              go      verb      2             hello         verb          2 
 1              go      verb      2             hello         verb          2 
 1              go      verb      2             hello         verb          2 

同样,其他字段也根据它们在表中的值重复,但我想成为这样的结果

WordId    WordName MeaningidE wordclass MeaningNameE WordclassA MeaningidA MeaningNameA 
1          go         1         verb       hello      verb       1             ራቀ 
Null       Null       2         verb       hello      verb       2             ራቀ

其余领域也是如此

h如何通过删除重复的行来编写显示为所需查询的查询?

4

1 回答 1

0

如果您可以格式化您的答案,那就太好了。从目前的情况来看,任何人都无法理解。
我想您的解决方案是使用 aGROUP BY column_name来获取重复项的字段。
下次尝试尽可能清晰地格式化您的问题。

于 2013-11-06T22:57:03.713 回答