
select * from
(
select
PartTran.Company as 事业部
,PartTran.JobNum as 工单号
,PartTran.PartNum as 物料编码
,Part.PartDescription as 物料描述
,PartTran.UM as 单位
,(case when PartTran.UM then PartTran.TranQty*乘数 else PartTran.TranQty end) as 数量
from Erp.PartTran
inner join Erp.Part as Part
on PartTran.PartNum = Part.PartNum
and PartTran.Company = Part.Company
where PartTran.TranType = 'STK-MTL'
and PartTran.UM <>'支'
and PartTran.UM <>'米'
and PartTran.UM <>'个'
)t
where 1=1
or (PartTran.UM and t.数量 = 你要的数)
1、新建一个test数据库,在数据库里创建一张data数据表,在表内插入5条测试数据。
2、新建一个php文件,命名为test.php。
3、在test.php文件内,使用header()方法设置文件执行的编码为utf8,避免输出中文时产生乱码。
4、在test.php内,使用数据库账号、密码、利用mysqli创建数据库连接,并使用set_charset()方法设置获得数据的编码为utf8,同时,使用if语句判断连接数据库是否成功,如果连接不成功,输出错误信息。
5、在test.php文件内,编写sql语句,使用TO_DAYS()分别获得当前的天数和数据表ctime字段数据的天数,两者之差小于3天,即前三天,以此为条件查询data数据表的数据。
6、在浏览器运行test.php文件,查看程序执行的结果,就完成了。
需要准备的材料分别是:电脑、sql查询器。
1、首先,打开sql查询器,连接上相应的数据库表,以stu2表查询age>10的数据为例。
2、点击“查询”按钮,输入:select id, IF(sex=1, '男', '女') as sex from stu2 where age >5。
3、点击“运行”按钮,此时用where查询出了age>5的数据,并且之后用了if条件判断性别。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)