sql查找不重复记录

http://zhidao.baidu.com/question/66282784.html?fr=qrl&cid=93&index=2

用 Distinct 子句呀
select distinct * from [yourtable]
或
select distinct [字段名1],[字段名2] from [yourtable]
 

防止重复插入记录sql实现方法

更多详细内容请查看:http://www.111cn.net/database/mysql/38213.htm

SQL语句判断空值相等

http://faq.dev.yesky.com/question-10138.html

 SQL语句判断空值相等 (离问题结束还有0天0小时) SQL code Create Table testa(t1 varchar(10),t2 varchar(10),t3 varchar(10),t4 varchar(10))
Create Table testb(t1 varchar(10),t2 varchar(10),t3 varchar(10),t4 varchar(10))

Insert into testa select \'hello\',\'11\',\'441\',\'441\'
union select \'word\',\'21\',\'441\',\'441\'
union select \'word\',\'21\',\'442\',\'442\'
union select \'word2\',\'212\',\'442\',\'442\'

Insert into testb select \'hello\',\'11\',\'xxx\',\'xxxx\'
union select \'word\',\'21\',\'xxx\',\'xxxx\'
select * from testa
select * from testb
select * from testa a where not exists(select * from testb b where a.t1=b.t1 and a.t2=b.t2 and a.t3=b.t3 and a.t4=b.t4)



上面是在论坛上看到一个比对表内容变化的例子,可以精确到每个字段。

现在出现一个问题就是如果 某一个字段 在两个表中都为空 用 a.t4=b.t4 的话 两个字段不相等,虽然没有做任何更改,仍然得到了这个记录。因为NULL 的判断不能用=号 要用 IS NULL 。
有没有解决这个问题的方法? 就是两个字段都为NULL的时候不让出现在这个结果里

还有,如果有更好的比对两个表的方法也烦请回答下, 要求能得到的结果 A表 和 B表相比 B新增加的,B修改过的 记录集。 然后我可以用程序反映到A表去。

mysql 中用sql判断两个字段是否相等

http://zhidao.baidu.com/question/178599402.html

比如
字段a varchar(200)      数据:  abcd
字段b varchar(1000)    数据:  15,石家庄|15,石家庄|15,石家庄|15,石家庄|

字段b 需要以 |  分割。也可以说有几个 |  就算字段b的长度是几。
15,石家庄|     这算长度1。
查询字段a和字段b长度不等的数据:
select * from 表 where length(a) <> length(b)

正常是length(b)  ,但现在字段b是用|分割的,怎么写

问题补充:

yang280974817大哥你看花眼了吧,回答不对题啊。
 
mysql具体语法不太清楚,但可以用

replace方法不知是否支持

length(b)-length(replace(b,'|',''))作为长度比较
原文地址:https://www.cnblogs.com/chulia20002001/p/2355676.html