nar86 Ответов: 1

Как изменить SQL-запрос с помощью внутреннего соединения


select  a.transaction_id, a.slip_date,a.temp_transaction_id,a.transaction_item_group_id,a.transaction_item_type_id,a.product_grade_id, a.unit_id,a.price_per_unit,a.total_price,a.actual_amount,a.paid_amount,a.due_amount,a.buying_agent_id,a.currency_id,a.transactee_type_id, a.quantity,a.lot_id,a.std_quantity,a.finance_type,a.slip_no,a.distribution_type,a.years_reimburse,b.farmerseason,b.regionname,b.zonename,b.sectionname,b.villagename,
a.transactee_id,b.lastname + ' ' + b.firstname + ' ' + b.surname as farmername,
c.transaction_item_type_code,c.transaction_item_type_name,d.transaction_item_group_id,d.transaction_item_group_name,e.location,a.status from [transact].[transaction_item] a,
tbl_farmerregistration_ivorycoast b,[master].[transaction_item_type] c,[master].[transaction_item_group] d,[master].[transaction_location_item_type] e 
where a.transactee_id = b.farmersapcode
 and a.transaction_item_type_id = c.transaction_item_type_id 
 and a.transaction_item_group_id = d.transaction_item_group_id  and e.transaction_item_id = c.transaction_item_type_id 
  and a.status = 'new' and b.isactive = '1' and b.farmersapcode = '1111290'


из приведенного выше запроса как перейти во внутреннее условие соединения

пожалуйста дайте мне знать

Что я уже пробовал:

select  a.transaction_id, a.slip_date,a.temp_transaction_id,a.transaction_item_group_id,a.transaction_item_type_id,a.product_grade_id, a.unit_id,a.price_per_unit,a.total_price,a.actual_amount,a.paid_amount,a.due_amount,a.buying_agent_id,a.currency_id,a.transactee_type_id, a.quantity,a.lot_id,a.std_quantity,a.finance_type,a.slip_no,a.distribution_type,a.years_reimburse,b.farmerseason,b.regionname,b.zonename,b.sectionname,b.villagename,
a.transactee_id,b.lastname + ' ' + b.firstname + ' ' + b.surname as farmername,
c.transaction_item_type_code,c.transaction_item_type_name,d.transaction_item_group_id,d.transaction_item_group_name,e.location,a.status from [transact].[transaction_item] a,
tbl_farmerregistration_ivorycoast b,[master].[transaction_item_type] c,[master].[transaction_item_group] d,[master].[transaction_location_item_type] e 
where a.transactee_id = b.farmersapcode
 and a.transaction_item_type_id = c.transaction_item_type_id 
 and a.transaction_item_group_id = d.transaction_item_group_id
  and e.transaction_item_id = c.transaction_item_type_id 
  and a.status = 'new' and b.isactive = '1' and b.farmersapcode = '1111290'

из приведенного выше запроса как перейти во внутреннее условие соединения

пожалуйста дайте мне знать

1 Ответов

Рейтинг:
2

CHill60

Это очень старомодный способ соединения столов.

SELECT  a.transaction_id, a.slip_date,a.temp_transaction_id,a.transaction_item_group_id,
a.transaction_item_type_id,a.product_grade_id, a.unit_id,a.price_per_unit,a.total_price,
a.actual_amount,a.paid_amount,a.due_amount,a.buying_agent_id,a.currency_id,a.transactee_type_id, 
a.quantity,a.lot_id,a.std_quantity,a.finance_type,a.slip_no,a.distribution_type,a.years_reimburse,b.farmerseason,b.regionname,b.zonename,b.sectionname,b.villagename,
a.transactee_id,b.lastname + ' ' + b.firstname + ' ' + b.surname as farmername,
c.transaction_item_type_code,c.transaction_item_type_name,d.transaction_item_group_id,d.transaction_item_group_name,e.location,a.status 

FROM [transact].[transaction_item] a
INNER JOIN tbl_farmerregistration_ivorycoast b ON a.transactee_id = b.farmersapcode
INNER JOIN [master].[transaction_item_type] c ON a.transaction_item_type_id = c.transaction_item_type_id
INNER JOIN [master].[transaction_item_group] d ON a.transaction_item_group_id = d.transaction_item_group_id
INNER JOIN [master].[transaction_location_item_type] e ON e.transaction_item_id = c.transaction_item_type_id 
WHERE 
	a.status = 'new' and b.isactive = '1' and b.farmersapcode = '1111290'