Joining view and tables in sql server -


i have following tables.

customer customer_id, customer_name

customer_details customer_id,phone_no,address

order_details order_id,customer_id,order_type

i have created view following

  create  view orders_analysis   select c.customer_id,cd.phone_no,od.order_id   customer c        inner join order_details od           on c. customer_id=od. customer_id        inner join c. customer_id=cd. customer_id           cd. customer_id=c.customer_id 

now using above view , pre mentioned tables have extract records in view of particular order_type.

can guys suggest me method.

first of all, have mistake in view, correct view after fix mistakes

create view orders_analysis   select c.customer_id,cd.phone_no,od.order_id   customer c      inner join order_details od         on c.customer_id = od.customer_id      inner join customer_details cd          on c.customer_id = cd.customer_id 

now want extract records in view of particular order_type.

solution one:- because dont have column order_type in view use inner join

select *   orders_analysis oa       inner join order_details od         on oa.order_id = od.order_id  od.order_type = value here 

solution two:-

otherwise add order-type column in view

create view orders_analysis       select c.customer_id,cd.phone_no,od.order_id,od.order_type       customer c          inner join order_details od             on c.customer_id = od.customer_id          inner join customer_details cd              on c.customer_id = cd.customer_id 

and use

select * orders_analysis order_type =  value here 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -