且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

唯一记录的SQL命令帮助。

更新时间:2023-02-05 17:31:24

2月16日下午12:50,mscu ... @ gmail.com写道:
On Feb 16, 12:50 pm, mscu...@gmail.com wrote:

什么是语法用于获取以下内容的sql命令。


我想从表中提取一些字段,但其中一个

字段需要是唯一的。


例如,如果我有一个客户表,我想得到每个唯一的

客户编号,但我也希望得到客户的姓名,地址,

电子邮件地址等。语法是什么?


我正在尝试使用DISTINCTROW但无济于事。如果我使用DISTINCT,

我如何拉入其他领域?


TIA。
What is the syntax for an sql command to get the following.

I want to pull in a handful of fields from a table but one of the
fields needs to be unique.

For example, if I have a customer table and I want to get each unique
customer number but I also want to get the customer''s name, address,
email address, etc. What is the syntax?

I am trying to use DISTINCTROW but to no avail. If I use DISTINCT,
how do I pull in the other fields?

TIA.



这有点令人困惑,可能是因为桌子没有更好地规范化了。

为什么会客户不止一次在客户表中?更进一步,

为什么会有不同的信息附加到同一个cutomer

号码?客户表真的应该只包含一次

客户的信息。

This is a little confusing, perhaps due to the tables not being
normalized better.
Why would a customer be in a ''customer table'' more than once? Futher,
why would there be different information attached to the same cutomer
number? A customers table really should contain information about a
customer only once.


2月16日下午12:29,storrboy < storr ... @ sympatico.cawrote:
On Feb 16, 12:29 pm, "storrboy" <storr...@sympatico.cawrote:

2月16日下午12:50,mscu ... @ gmail.com写道:
On Feb 16, 12:50 pm, mscu...@gmail.com wrote:

sql命令获取以下内容的语法是什么。
What is the syntax for an sql command to get the following.


我想从表中提取一些字段,但其中一个

字段需要是唯一的。
I want to pull in a handful of fields from a table but one of the
fields needs to be unique.


例如,如果我有一个客户表,我想获得每个唯一的

客户编号,但我也想要获取客户的姓名,地址,

电子邮件地址等。语法是什么?
For example, if I have a customer table and I want to get each unique
customer number but I also want to get the customer''s name, address,
email address, etc. What is the syntax?


我正在尝试使用DISTINCTROW,但无济于事。如果我使用DISTINCT,

如何拉入其他字段?
I am trying to use DISTINCTROW but to no avail. If I use DISTINCT,
how do I pull in the other fields?


TIA。
TIA.



这有点令人困惑,可能是因为桌子没有更好地规范化了。

为什么会这样客户不止一次在客户表中?更进一步,

为什么会有不同的信息附加到同一个cutomer

号码?客户表真的应该只包含一次

客户的信息。


This is a little confusing, perhaps due to the tables not being
normalized better.
Why would a customer be in a ''customer table'' more than once? Futher,
why would there be different information attached to the same cutomer
number? A customers table really should contain information about a
customer only once.



相信我,我必须在这里工作的数据库不是由我创建的,并且

关系设置得很差。

Trust me, the db I have to work with here was not created by me and
the relationships are set up very poorly.


2月19日上午9:20,mscu ... @ gmail.com写道:
On Feb 19, 9:20 am, mscu...@gmail.com wrote:

2月16日下午12:29,storrboy < storr ... @ sympatico.cawrote:
On Feb 16, 12:29 pm, "storrboy" <storr...@sympatico.cawrote:

2月16日下午12:50,mscu ... @ gmail.com写道:
On Feb 16, 12:50 pm, mscu...@gmail.com wrote:


获取以下内容的sql命令的语法是什么。
What is the syntax for an sql command to get the following.


我想从一张桌子中拉出一些字段但是其中一个字段/>
字段必须是唯一的。
I want to pull in a handful of fields from a table but one of the
fields needs to be unique.


例如,如果我有一个客户表,我想得到每个唯一的

客户编号,但我也希望得到客户的姓名,地址,

电子邮件地址等。语法是什么?
For example, if I have a customer table and I want to get each unique
customer number but I also want to get the customer''s name, address,
email address, etc. What is the syntax?


我正在尝试使用DISTINCTROW,但无济于事。如果我使用DISTINCT,

如何拉入其他字段?
I am trying to use DISTINCTROW but to no avail. If I use DISTINCT,
how do I pull in the other fields?


TIA。
TIA.


这有点令人困惑,可能是由于桌子没有更好地规范化了。

为什么客户不止一次进入客户表?更进一步,

为什么会有不同的信息附加到同一个cutomer

号码?客户表真的应该只包含一次

客户的信息。
This is a little confusing, perhaps due to the tables not being
normalized better.
Why would a customer be in a ''customer table'' more than once? Futher,
why would there be different information attached to the same cutomer
number? A customers table really should contain information about a
customer only once.



相信我,我必须在这里工作的数据库不是由我创建的和

关系设置得很差。


Trust me, the db I have to work with here was not created by me and
the relationships are set up very poorly.



我没有像您一样的桌子可以试穿,但如果有

不同的信息附在同一个客户身上数字然后我

认为没有标准化你可以做的***就是使用分组。

这应该合并所有类似的记录,但复制其中的一个或

更多字段不同。


I don''t have a table like your to try things on, but if there is
different information attached to the same customer number then I
think the best you can do without normalizing is to use groupings.
This should merge all like records but duplicate the ones where one or
more fields are different.