我有两个表,SQL命令,嵌套的SQL
- 计费( “列”(bill_no,ITEM_NO))//法案没有可以在数据库中重复
- 项目( “列”(ITEM_NO (PrimaryKey的),名称,类型,价格)
我想知道的任何可能的查询,以显示我:
| bill_no | item_no | name | type | price |
我想说明* bill_no *和* * ITEM_NO项目表全光照的计费表的n值* ITEM_NO * coloumn
谢谢。
我有两个表,SQL命令,嵌套的SQL
我想知道的任何可能的查询,以显示我:
| bill_no | item_no | name | type | price |
我想说明* bill_no *和* * ITEM_NO项目表全光照的计费表的n值* ITEM_NO * coloumn
谢谢。
取决于你想与您的查询做什么,这里有一些选择:
select billing.bill_no
, billing.item_no
, item.name
, item.type
, item.price
from billing, items
where billing.item_no = items.item_no
OR
select billing.bill_no
, billing.item_no
, item.name
, item.type
, item.price
from billing
join items on billing.item_no = items.item_no
where billing.bill_no = 1234
您可以使用一个简单连接。
select billing.bill_no
,billing.item_no
,items.name
,items.type
,items.price
from billing
join items on items.item_no = billing.item_no
Select b.bill_no
,i.item_no
,i.name
,i.type
,i.price
from billing b
,items i
where i.item_no=b.item_no;
你有没有尝试去编写查询? – Vinnie 2012-03-06 17:18:48
-1没有尝试 – 2012-03-06 17:23:07