select Item.ItemID,Item.ItemNo,ItemName,
(select Price from ItemPrice,Item where Item.ItemID=ItemPrice.ItemID and 
ItemPrice.ItemPriceID='1') as Price1,
(select Price from ItemPrice,Item where Item.ItemID=ItemPrice.ItemID and ItemPrice.ItemPriceID='2') as Price2,
(select Price from ItemPrice,Item where Item.ItemID=ItemPrice.ItemID and ItemPrice.ItemPriceID='3') as Price3
from Item,ItemPrice
Where Item.ItemID=ItemPrice.ItemID

解决方案 »

  1.   


    你可以先分開來把每次的price取出來,然後通過ItemID把3個連起來.有的時候不一定要一次行就寫出來分步寫容易理解.
    樓上就是這個意思
      

  2.   

    楼上的朋友,执行SQL语句老是报错“子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。”怎么处理啊!!!
      

  3.   

    用sql的left join可以实现。