我有两张桌子,
- billing ("columns"(bill_no,item_no)) //账单号可以在数据库中重复
- 项目(“列”(item_no(primarykey),名称,类型,价格)
我想知道任何可能的查询来告诉我这个:
|bill_no|item_no|名称|类型|价格|
我想显示帐单表的 *bill_no* 和 *item_no*项目表的 n 值使用*item_no* 列
谢谢你。
我有两张桌子,
我想知道任何可能的查询来告诉我这个:
|bill_no|item_no|名称|类型|价格|
我想显示帐单表的 *bill_no* 和 *item_no*项目表的 n 值使用*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;
根据您要对查询执行的操作,以下是一些选项:
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
您可以使用简单的联接。
select billing.bill_no
,billing.item_no
,items.name
,items.type
,items.price
from billing
join items on items.item_no = billing.item_no