$str = trim($str)
$str = preg_replace("</P>","1234a3211",$str)
$str = preg_replace("</p>","1234a3211",$str)
$str = preg_replace("<br/>","1234a3211",$str)
$str = preg_replace("/<(.[^>]*)>/","",$str)
$str = preg_replace("/([\r\n])[\s]+/","",$str)
$str = preg_replace("/-->/","",$str)
$str = preg_replace("/<!--.*/","",$str)
$str = preg_replace("/&(quot|#34)/","",$str)
$str = preg_replace("/&(amp|#38)/", "/&/",$str)
$str = preg_replace("/&(lt|#60)/", "/</",$str)
$str = preg_replace("/&(gt|#62)/", ">",$str)
$str = preg_replace("/&(nbsp|#160)/", "",$str)
$str = preg_replace("/&(iexcl|#161)/", "/\xa1/",$str)
$str = preg_replace("/&(cent|#162)/", "/\xa2/",$str)
$str = preg_replace("/&(pound|#163)/", "/\xa3/",$str)
$str = preg_replace("/&(copy|#169)/", "/\xa9/",$str)
$str = preg_replace("/(\d+)/", "",$str)
$str = preg_replace("/</", "",$str)
$str = preg_replace("/>/", "",$str)
$str = preg_replace("/\r\n/", "",$str)
$str = preg_replace("/1234a3211/", "/<br/>/",$str)
return $str
}
selectdistinct可以去掉重复记录。
disctinct将重复的记录忽略,但它忽略的是完全一致的重复记录,而不是其中某个字段重复的记录,或者说,distinct查询一个字段时好使,多个字段就不好使。
所以用聚合函数和group
by实现
注意:group
by只能跟聚合函数搭配使用
例表
ID
username
password
TRDESC
1
A
abcdef
QR
2
A
abcdef
W34
3
A
bbbbbb
AD
4
B
aaaaaa
asdf
查询username和password组合起来的条件不能重复的查询结果(这个都能重复,不能不说这是个烂摊子)
select
*
from
mytable
where
ID
in(select
max(ID)
from
mytable
group
by
username,password)
当username和password重复时,取ID最小的记录:
select
*
from
mytable
where
ID
in(select
min(ID)
from
mytable
a
group
by
username,password)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)