如何使用sql查询基于大小的项目? [英] How to query items based on size with sql?

查看:121
本文介绍了如何使用sql查询基于大小的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 来自两个表:Item&方框,我希望 确定项 table <中的每个项 / span>属于  Box_ID  基于 高度宽度。 

如果 height width 项目比高度& width 然后此项目属于 box_id。示例:I1 4 1 B1 Box 1
每个项目 只属于 一个box_id。
如何
sql 中查询 返回 以下结果表?



< img width ='500'src =http://i.stack.imgur.com/DwCAy.jpg/>



P / s:我已将问题放在 stackoveflow 上[ ^ ]

解决方案

尝试这样的查询:



 选择 A.ITEM_ID,
A.HEIGHT,
A.WIDTH,
B.BOX_ID,
B.BOXNAME
FROM
项目A
INNER JOIN
BOX B ON A.Height = B.HEIGHT OR A.Width = B.Width


From two table: Item & Box, I want to determine each item in Item table belong to Box_ID in Box table based on height and width.

    If height and width of item which greate than height & width of box then this item belong to that box_id. Example: I1  4 1 B1 Box 1
    Each item is only belong to a box_id.
How to query in sql to return as the below result table?


<img width='500' src="http://i.stack.imgur.com/DwCAy.jpg"/>

P/s: I've put the question at stackoveflow[^]

解决方案

Try like this query :

Select  A.ITEM_ID ,
		A.HEIGHT,
		A.WIDTH,
		B.BOX_ID,
		B.BOXNAME
	FROM
		ITEM A 
			INNER JOIN 
		BOX B ON A.Height=B.HEIGHT OR A.Width=B.Width


这篇关于如何使用sql查询基于大小的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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