Question:

How to create a view with a column isn't column of any table in database?

by  |  earlier

0 LIKES UnLike

My database have 2 table: tbl_product and tbl_Order. There is a foreign key constraint between them. I want to create a view named as view_Product_Order as follow: It contain 2 column: Product_Name and Product_Ordered, Product_Ordered will display 1 if exists a Product_ID in tbl_Product also exists in tbl_Order otherwise display 0. Please help me and sorry about my English. Thank you.

 Tags:

   Report

1 ANSWERS


  1. My suggestion is you should use a left join statement for your query for VIEW.

    heres a sample:

    select tbl_Order.OrderId, tbl_product.Product_Name from

    tbl_Order left join tbl_product on tbl_product.Product_Id on tbl_Order.ProductId;

    hope this helps

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.