• 多表查询语句写法、数据库数字如何转化为汉子、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);
                }

  • 相关阅读:
    后台管理UI
    14.6.3.2 Configuring Multiple Buffer Pool Instances 配置多个Buffer Poll 实例:
    14.6.3.1 The InnoDB Buffer Pool
    innodb_buffer_pool_instances and innodb_buffer_pool_size的关系
    猪肉都被绑上了“家族标签”,大数据已波及到农牧业!
    14.6.2 Configuring InnoDB for Read-Only Operation
    jquery EasyUI datagrid重新加载传参问题
    分布式系统事务一致性解决方案
    面试题整理
    dump iot表
  • 原文地址:https://www.cnblogs.com/lykbk/p/lyk19900723_daima.html
Copyright © 2020-2023  润新知