>I have a table named tb_quotedetail. Inside this table i have 4 fields. F1) IDMASTER (n) F2) ORIGINID (n) F3)DESTINATIONID (n) F4)PRODUCTID(n)
>origin and destination id are associated with the autoid in the table tb_city. and product id is associated with the autoid of tb_product.
>So i want to do a select in tb_quotedetail where the id master is 11 and i want the product name , city origin name and city destination name. how can i do it, thanks
select Ci1.City as CityOriginaName, Ci2.City as DestinationName, P.ProductName
from Tb_QuoteDetail T
INNER JOIN Tb_City Ci1 on T.OriginID = Ci.AutoID ;
INNER JOIN Tb_City Ci2 on T.DestinationID = Ci.AutoID ;
INNER JOIN tb_Product P on T.ProductID = P.AutoID where T.MasterID = 11
Something like that.
If it's not broken, fix it until it is.
My Blog