两种写法,区别在最后一行,查询结果一样
select v.id id, product_id, t.id comp_id, comp_value, comp_file, time, file_path, cmpt_name, work_name, rate_time, real_time, count_down, book_id, cmpt_left, cmpt_top,cmpt_width, cmpt_height, font_size, font_name, cmpt_type, d.dict_label as cmpt_type_name, num_point, is_equal_begin, is_required, is_limit,is_equal_end, num_begin, num_end, cmpt_line, cmpt_operator, cmpt_role, cmpt_user, v.user_id user_id
from cer_book_component t
left join sys_dict_data d on d.dict_value = t.cmpt_type and dict_type='cer_component_type'
left join (select * from cer_book_value where product_id = 4 ) v on t.id = v.comp_id
select v.id id, product_id, t.id comp_id, comp_value, comp_file, time, file_path, cmpt_name, work_name, rate_time, real_time, count_down, book_id, cmpt_left, cmpt_top,cmpt_width, cmpt_height, font_size, font_name, cmpt_type, d.dict_label as cmpt_type_name, num_point, is_equal_begin, is_required, is_limit,is_equal_end, num_begin, num_end, cmpt_line, cmpt_operator, cmpt_role, cmpt_user, v.user_id user_id
from cer_book_component t
left join sys_dict_data d on d.dict_value = t.cmpt_type and dict_type='cer_component_type
left join cer_book_value v on product_id = 4 and t.id = comp_id
两种查询都是259条记录
写法一:
left join (select * from cer_book_value where product_id = 4 ) v on t.id = v.comp_id
写法二:
left join cer_book_value v on product_id = 4 and t.id = comp_id