When you ran this query,
what was it that wasn't right about it?
Well, it seems to think
that each student is his or
her own roommate, and it lists each pair
of roommates twice in alternating order.
There are a lot of ways to fix this,
but here's just one of them.
By asking only for the rows where
this id, is less than that id.
We eliminate the rows where they're
equal, in other words the same student.
And, we eliminate one out
of each pair of duplicates.
،حينما قمتم بتشغيل هذا الاستعلام
فما الشيء الذي لم يكن صحيحًا بشأنه؟
حسنًا، يفترض الاستعلام أن
كل طالب في موضع
زميله في الغرفة، ويسرد كل
.زميلين مرتين بترتيب متناوب
،توجد عدة سبل لإصلاح هذا
.ولكن سنقدم واحدة فقط منها
من خلال الاستعلام فقط عن الصفوف التي يكون فيها
.هذا المعرف أقل من ذلك المعرف
نتخلص من الصفوف التي يكون فيها
.المعرفين متساويين، وبعبارة أخرى من نفس الطالب
ونتخلص من
.طالب واحد من الطالبين المتكررين
Quando você executou esta consulta,
o que havia de errado com ela?
Bem, ela parece pensar
que cada aluno é seu
próprio colega de quarto, e ela lista cada par
de colegas de quarto duas vezes em ordem alternada.
Existem várias formas de corrigir isso,
mas aqui está apenas uma delas.
Solicitando apenas as linhas onde
esta id é menor que essa id.
Eliminamos as linhas onde elas são
iguais, em outras palavras o mesmo aluno.
E, eliminamos um de
cada par de duplicatas.
当你运行这条查询时 不正确的地方在哪里?
看起来它认为每个学生都是他或她自己的室友
而且它以交替的顺序把每对室友列了两遍
有很多方法可以纠正这个问题 这里只是其中一个
它只要求返回这个 ID 小于那个 ID 的行
我们排除了 ID 相等的行 换句话说 排除了相同的学生
而且 我们排除了每对重复值中的一个