在sql server中,我们有一个表,其中有许多列. [英] in sql server we have a table in which many of column..

查看:76
本文介绍了在sql server中,我们有一个表,其中有许多列.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在sql server中,我们有一个表,其中许多列,例如Fname Lname U_id和Uname.Uname是主键.有很多重复的数据,但我没有重复的数据.其中Uname =?我要代替?....

in sql server we have a table in which many of column such as Fname Lname U_id and Uname.Uname is primary key..i get the velue of Fname Lname. there are many data is repeated but i get not repeated data. where Uname=? what i do in place of ?....

推荐答案

做什么?如果您在谈论基本查询,请查看以下内容:
If you are talking about the basic query then have a look at this:
SELECT * FROM tbUserDetails WHERE UserNAME = ?


这里 ?表示您要从数据库中获取哪些用户信息.您必须对此清楚.您可以像这样使用:


Here ? means which user information you want to fetch from database. You''ll have to be clear on that. You can use like:

SELECT * FROM tbUserDetails WHERE UserNAME = 'amit'


*表示表中的所有列.如果只需要表中的特定列,则可以将 *替换为用逗号分隔的列名.像这样尝试:


Here * means all the columns from the table. If you want only specific columns from table then you can replace the * to your column names separated with comma. Try like this:

SELECT FName, LName, Address, EmailID, PhoneNo FROM tbUserDetails WHERE UserNAME = 'amit'



希望对您有所帮助.
--Amit



Hope it helps.
--Amit




我了解您是该技术的新手,但您不应使用UserName作为主键,建议我使用UserID作为主键.它还将为索引目的提供更多帮助.

如果您正在运行Web应用程序,那么我建议您使用UserId作为GUID而不是简单的数字值.如果需要唯一的用户名,可以将唯一键设置为userName.

希望您知道将主键从用户名更改为用户ID的原因.
Hi,

I understand you are very new with the technology but you should not use UserName as the primary key, Insted i suggest you to use UserID as the primary key. It will also help more for indexing purpose.

If you are running web application then i suggest you to use UserId as GUID instead of simple numeric value. You can set Unique key to userName if you want unique username.

Hope you got the reason for changing primary key from username to userid.


您好,

据我了解,FName,LName列具有重复的值,而UName是主键.看到,在保存自身的同时,您可能会担心,您将不允许重复的FName和LName值.因此,仅对UName应用条件不足以获取不同的值.因此,在插入数据时,检查是否存在相同的FName和LName值.到目前为止,对于不同的值,只需查询不同的FName和LName.

希望对您有所帮助.
Hi,

As i understood, FName, LName columns have repeated values whereas UName is Primary key. See, while saving itself you could have causious that, you would not allow repeated FName and LName values. So, just by applying condition to UName is not sufficient to get distinct values. So, while inserting the data check for the existence of same FName and LName values. As of now for distinct values just query for distinct FName and LName.

hope it helps.


这篇关于在sql server中,我们有一个表,其中有许多列.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆