• 多表查询语句写法、数据库数字如何转化为汉子、Sql语句拼接


    一、今天收获是学会了写多表查询语句,以及如何将数据库文字转化为汉子

    多表查询语句的写法:

    select a.字段名,b.字段名,c.字段名,d.字段名 ,case  when a. 字段名=0  then '汉字'  when a.字段名=1 then '汉字'   end as 字段别名  from 表名1 as a inner join 表名2 as b  On a.字段名=b.字段名 inner join 表名3 as c  On a.字段名=c.字段名  inner join 表名4 as d  On a.字段名=d.字段名.

    二、Sql语句拼接

        StringBuilder sb = new StringBuilder();
                sb.Append("Select zy.zymc ,gv.postName,dv.UnitName ,sxzy,u.bkUserID,UserName,u.sfzh,u.bmxlh,u.zkzh,case when u.ifjf=0 then '未交费' when  u.ifjf=1 then '已交费成功' end as iss , case when u.ifsh=0 then '未审核' when u.ifsh=1 then '审核通过' when u.ifsh=2 then '审核不通过' when u.ifsh=3 then '审核通过缴费成功'   end as ifsh  from  bm_examcj as zy inner join bm_ExamUser  as u On zy.zkzh=u.zkzh  inner join  bm_post as gv On gv.postID=u.postID inner join bm_ExamUnit as dv On dv.UnitID=u.bkUnitID  where 1=1 ");
                if (txtxm.Text != string.Empty)
                    sb.Append(" and UserName like '%" + txtxm.Text.Trim() + "%' ");
                if (txtbmxlh.Text != string.Empty)
                    sb.Append(" and bmxlh like '%" + txtbmxlh.Text.Trim() + "%' ");
                if (txtzy.Text != string.Empty)
                    sb.Append(" and zy like '%" + txtzy.Text.Trim() + "%' ");
                dp.CommandText = sb.ToString();
                DataTable dt = dp.ExecuteDataTable();
                if (dt.Rows.Count != 0)
                {
                    this.DataGridView1.BindData(dt);
                }

  • 相关阅读:
    多项式计算公式
    题目:求1+2!+3!+...+20!的和。
    01背包问题
    实现sqrt算法
    R语言中assign函数
    R语言中mode和class的区别
    org.Mm.eg.db包的安装
    正则表达式中.* 和 .*?的区别
    正则表达式中 + 的作用
    正则表达式中.和*的区别
  • 原文地址:https://www.cnblogs.com/lykbk/p/lyk19900723_daima.html
Copyright © 2020-2023  润新知