请教一个SQL语句,如何查询一列中重复的值

dajiahaoma444 2011-01-27 08:11:19
库中有一列是叫
userpass
保存用户的密码
类型是 char(40)

我想知道哪几行的一样
这个SQL语句怎么写啊
...全文
1155 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
dajiahaoma444 2011-01-27
  • 打赏
  • 举报
回复
呵,谢谢了。刚翻了下书。
用别名搞定了
谢谢
select * from table1 as t,table1 where table1.userpass=t.userpass and table1.id!=t.id;
ACMAIN_CHM 2011-01-27
  • 打赏
  • 举报
回复
锻炼一下找不同。 我也本以为楼主一定会复制粘贴。

[Quote== #1楼]select * from table1 a
where exists (select 1 from table1 where userpass=a.userpass and id!=a.id)[/Quote]


select * table1 a where exists(select 1 from table1 where userpass=a.userpass and id!=a.id;
dajiahaoma444 2011-01-27
  • 打赏
  • 举报
回复
呵。。见笑了。
我以为这个错误大家应该闭着眼睛就知道了
mysql> select * table1 a where exists(select 1 from table1 where userpass=a.userpass and id!=a.id;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near '' at
line 1
ACMAIN_CHM 2011-01-27
  • 打赏
  • 举报
回复
为什么懒到连错误信息都不愿意贴全?!

显然你的语句没有写对,但你打算让别人怎么猜呢?!

问题说明越详细,回答也会越准确!参见如何提问。(提问的智慧
dajiahaoma444 2011-01-27
  • 打赏
  • 举报
回复
我的表名字叫 table1 ID的字段名也叫id
但是为什么总提示我语法错误

ERROR 1064 (42000)....什么什么的
ACMAIN_CHM 2011-01-27
  • 打赏
  • 举报
回复
select * from table1 a
where exists (select 1 from table1 where userpass=a.userpass and id!=a.id)

56,675

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧