-1

我有两张桌子,

  1. billing ("columns"(bill_no,item_no)) //账单号可以在数据库中重复
  2. 项目(“列”(item_no(primarykey),名称,类型,价格)

我想知道任何可能的查询来告诉我这个:

|bill_no|item_no|名称|类型|价格|

我想显示帐单表的 *bill_no* 和 *item_no*项目表的 n 值使用*item_no* 列

谢谢你。

4

3 回答 3

0
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;
于 2012-03-06T17:22:12.130 回答
0

根据您要对查询执行的操作,以下是一些选项:

select billing.bill_no
, billing.item_no
, item.name
, item.type
, item.price
from billing, items
where billing.item_no = items.item_no

或者

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
于 2012-03-06T17:20:15.257 回答
0

您可以使用简单的联接。

select billing.bill_no
        ,billing.item_no
        ,items.name
        ,items.type
        ,items.price
from billing
join items on items.item_no = billing.item_no
于 2012-03-06T17:21:24.263 回答