Asp.Net Hein

Asp.Net Hein

  • NA
  • 266
  • 167.3k

Primary key and foreign key

Sep 21 2015 1:00 AM
I create two tables.
 
One is StockAmount (Name{primary key}, Amount) and the another one is StockPrice(ID{Primary key with autogenerated}, Name{foreign key with StockAmount table}, Price)
 
And then I store some data to
 
StockAmount.
-a     100
-b     200
-c     300
 
StockPrice 
-1     a     20000
-2     b     15000
-3     c      25000
 
And then I retrieve the data like this.
 
Select StockAmount.Name,StockAmount.Quantity,StockPrice.Price from StockAmount,StockPrice where StockAmount.Name='a'
 
The result comes out
a     100   20000
b     200   20000
c      300   20000
 
I want only one line like
a      100    20000.
 
Please solve my problem and reply to me. Thanks a lot for your help. 

Answers (1)