php mysql 查询只返回第一条数据

php mysql 查询只返回第一条数据,第1张

1、首先用navicat新建一个数据database1,在database1数据库中新建一个表table2。

2、在table2中添加新的数据。

3、接着新建一个名称为mysql_query的数据库,在页面中用mysql_connect 函数与数据库建立连接。

4、用mysql_select_db函数选择要查询的数据库。

5、最后将mysql_query,php文件在浏览器中打开,查看查询到数据库中的内容的结果。

sql如何查询第一个数据的方法。

如下参考:

1.首先,双击“ManagementStudio”图标打开SQLServer。

2.继续打开SQLServer窗口,单击工具栏中的“newquery”图标。

3.在SQLServer第二窗口,输入来自SQL语句的查询数据到SQLServer数据库。

4.然后在SQLServer窗口,单击工具栏中的“execute”图标。

5.最后,在SQLServer窗口中,成功地显示了SQLServer数据库中的查询数据结果。

用 top 1来返回一行,

datediff(day,t1.FcheckDate, getdate())as 账龄 来进行日期相减

Select top 1 u2.fnumber as 仓库代码,u2.FName as 仓库名称,ti.fnumber as 物料代码 ,ti.FName as 物料名称 ,ti.FModel as 型号,u1.FBatchNo as 批号,

tm.FName as 基本单位,cast(u1.FQty as numeric(18,0)) as 基本单位数量,convert(nvarchar,t1.FDate,111) as 制单日期,

convert(nvarchar,t1.FcheckDate,111) as 入库日期,

datediff(day,t1.FcheckDate, getdate())as 账龄

from icinventory u1,t_ICItem ti,t_MeasureUnit tm,t_Stock u2,ICStockBill t1,ICStockBillentry t2

where tm.FItemID=ti.funitid and t1.FInterID=t2.FInterID and u1.FStockID=u2.FItemID and u1.FItemID=ti.FItemID

and u1.FQty>0

and u1.FBatchNo is not null

and u1.FBatchNo<>''and u1.FBatchNo<>'KB' and u1.FBatchNo<>'*'

and t1.FTranType=2

and t2.FBatchNo=u1.FBatchNo

and getdate()-convert(nvarchar,t1.FcheckDate,111)>15


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/sjk/6699414.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-26
下一篇 2023-03-26

发表评论

登录后才能评论

评论列表(0条)

保存