200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > SQL语句中字段的拼接

SQL语句中字段的拼接

时间:2022-08-26 09:17:20

相关推荐

SQL语句中字段的拼接

原始sql语句及效果如下:

string sq = @"select gx_plan.id,fk_sec.factory as 本厂编号, `order` as 序号,gx_plan.TotalOrder as 总工序数,note as 备注 from fk_sec,gx_planwhere (date='" + date + "' or '" + date + "'='') and (fk_sec.AorS='" + machine + "'or '" + machine + @"'='') and (gx_plan.machinetype='" + m + "'or '" + m + @"'='') and(fk_sec.id = gx_plan.fkid) order by beforesplitid desc ";

字段拼接后的语句及其效果:

string sq = @"select gx_plan.id,fk_sec.factory as 本厂编号, concat_ws('/', `order`, gx_plan.TotalOrder) as `序号/总工序数`,note as 备注 from fk_sec,gx_planwhere (date='" + date + "' or '" + date + "'='') and (fk_sec.AorS='" + machine + "'or '" + machine + @"'='') and (gx_plan.machinetype='" + m + "'or '" + m + @"'='') and(fk_sec.id = gx_plan.fkid) order by beforesplitid desc ";

注意:在sql语句中 ~号 和 ‘号 的区别

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。