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

  • 相关阅读:
    关于安卓9patch图片的探究
    android中系统时间
    android中的对话框
    swing界面刷新问题
    android中的xml解析全解
    android中listView下拉刷新
    次小生成树(poj 1679)
    poj 2312(bfs+priority_queue)
    poj 2060(最小路径覆盖)
    poj 1734 (最小环)
  • 原文地址:https://www.cnblogs.com/lykbk/p/lyk19900723_daima.html
Copyright © 2011-2022 走看看