加入MYSQL表并按两个字段排序? [英] Join MYSQL tables and sort by two fields?

查看:136
本文介绍了加入MYSQL表并按两个字段排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MYSQL中对表格进行排序时遇到问题.

I'm having a problem sorting my tables in MYSQL.

我的表格设置如下:

  • Order_ID
  • shipping_cost
  • 打印
  • ID
  • Order_ID
  • SKU位置

我想选择所有打印为FALSE的订单,还要按运输成本排序,然后按SKU_location排序

I want to SELECT all orders WHERE printed = FALSE but also sort by the shipping costs and THEN by the SKU_location

我如何将表连接到一个查询中,以便按Shipping_cost和SKU_location排序(其中print = false)?

How can I join the tables into one query so it sorts by shipping_cost and SKU_location where printed = false?

推荐答案

您可以通过以下方式进行隐式JOIN:

You can do an implicit JOIN in the following way:

SELECT * 
FROM Order_details od
JOIN Product_details pd
ON od.Order_ID = pd.Order_ID
WHERE od.printed = FALSE
ORDER BY od.shipping_cost, pd.SKU_location

每个表后面的文本将表重命名,以便在查询的后面部分方便参考(即代码"Database.Long_Table_Name ltn"将表重命名为"ltn")

The text following each table renames the table for easy reference in the later parts of the query (i.e. the code "Database.Long_Table_Name ltn" renames the table to "ltn")

这篇关于加入MYSQL表并按两个字段排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆