sql concat() 函数解释

2017-09-13 12:25:44来源:CSDN作者:genziisme人点击

分享

用于把两个字段串联起来

types表

id     name  pid  path      

12 男装    0   0,
13 女装    0  0,  
14 领带   12  0,12,
15 西装   12  0,12,

eg:

 $sql = select types.*,concat(path,id) p from types order by p ;

$data = $sql->exec();

echo "<pre>";

print_r($data);


最后输出结果为:

Array(    [0] => stdClass Object        (            [id] => 12            [name] => 男装            [pid] => 0            [path] => 0,            [p] => 0,12        )    [1] => stdClass Object        (            [id] => 14            [name] => 领带            [pid] => 12            [path] => 0,12,            [p] => 0,12,14        )    [3] => stdClass Object        (            [id] => 15            [name] => 西装            [pid] => 12            [path] => 0,12,            [p] => 0,12,15        )    [4] => stdClass Object        (            [id] => 13            [name] => 女装            [pid] => 0            [path] => 0,            [p] => 0,13        ))

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台