mysql 中使用 concat 函数 拼接字符串

MySQL concat函数可以连接一个或者多个字符串,如
select concat('10');
结果:10 
select concat('11','22','33');
结果
112233
MySQL的concat函数在连接字符串的时候,只要其中一个是NULL,那么将返回NULL
select concat('11','22',null);
结果

NULL


今天 试了一下,数据库中将域名 分为domain_prefix和domain_suffix ,使用domain查询

方法一:

String[] strings = domain.split("\\.");
String domain_Pre = strings[0];
String domain_suf = domain.substring(domain_Pre.length());

使用得到的domain_Pre和domain_suf 去查询数据库(仅二级域名可以,三级域名将会出错)

其中"." 要使用 “\\.”

方法二:

SELECT * FROM ddnsinf WHERE concat(domain_prefix,domain_suffix)="TFClokjq00b4.tfcddns.com" 

posted @ 2014-02-26 11:50  lxn91  阅读(327)  评论(0编辑  收藏  举报