• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php操作数据库看到og.id 、og.orderid=:orderid、g on g.id,是什么意思

php 搞代码 4年前 (2022-01-23) 20次浏览 已收录 0个评论
文章目录[隐藏]

pdo_fetchall(“select og.id,og.realprice,og.total,g.hascommission,g.nocommission, g.commission1_rate,g.commission1_pay,g.commission2_rate,g.commission2_pay,g.commission3_rate,g.commission3_pay from ” . tablename(shop_order_goods’) . ‘ og ‘ . ‘ left join ‘ . tablename(‘shop_goods’) . ‘ g on g.id = og.goodsid’ . ‘ where og.orderid=:orderid and og.uniacid=:uniacid’, array(
‘:orderid’ => $orderid,

每个字段前面都加了og.如og.id,og.realprice,这什么意思

数据库中有id和goodsid字段,但是g on g.id这种形式是什么意思。

还有 og.uniacid=:uniacid这种og.以及等号后面的:冒号是什么意思

回复讨论(解决方案)

XXX.xxx XXX 是别名

:uniacid 是参数化传参是的参数名

XXX.xxx XXX 是别名

:uniacid 是参数化传参是的参数名

别名是随便命名的是吗?这个别名是做什么用的,跟直接使用字段的区别在哪里?

g on g.id这种形式是什么意思。点前面还有字母和空格又加字母

og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ; 这里abc就是数据库名。

对于你的
… from ” . tablename(shop_order_goods’) . ‘ og ‘ . ‘ left join ‘ . tablename(‘shop_goods’) . ‘ g …
tablename(shop_order_goods’) 和 tablename(‘shop_goods’) 返回的是表名,可见并不是确定的值
而关联表达式 on g.id = og.goodsid 中,如果 g 和 og 不使用别名的话,就有得调用那两个函数,显得很臃肿了

og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ; 这里abc就是数据库名。

别名的意义是什么?

og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ; 这里abc就是数据库名。

别名的意义是什么?

可以写得短一些。

例如你表名是information_schema_member和information_abc,需要join

不使用别名
select information_schema_member.name,information_abc.addtime from information_schema_member join information_abc on information_schema_member.id=information_abc.uid;

使用别名
select a.name,b.addtime from information_schema_member as a join information_abc as b on a.id=b.uid;

og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ; 这里abc就是数据库名。

别名的意义是什么?

可以写得短一些。

例如你表名是information_schema_member和information_abc,需要join

不使用别名
select information_schema_member.name,information_abc.addtime from information_schema_member join information_abc on information_schema_member.id=information_abc.uid;

使用别名
select a.name,b.addtime from information_schema_member as a join information_abc as b on a.id=b.uid;

join加载了完成的数据库,然后其他调用数据本@文来源[email protected]搞@^&代*@码网(搞代gaodaima码库就可以使用别名是吗?

og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ; 这里abc就是数据库名。

别名的意义是什么?

可以写得短一些。

例如你表名是information_schema_member和information_abc,需要join

不使用别名
select information_schema_member.name,information_abc.addtime from information_schema_member join information_abc on information_schema_member.id=information_abc.uid;

使用别名
select a.name,b.addtime from information_schema_member as a join information_abc as b on a.id=b.uid;

看来确实如此,谢谢了


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php操作数据库看到og.id 、og.orderid=:orderid、g on g.id,是什么意思

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址