I have 3 tables :
1-Contracts -contracts_id -subject_contract -case_id
contracts_id | subject_contract | case_id
001 | name | 01
002 | name | 02
003 | name | 01
2-contracts_files -contracts_id -file_data
contracts_id | file_data
001 | image <varbinary(MAX)>
002 | image <varbinary(MAX)>
001 | image <varbinary(MAX)>
002 | image <varbinary(MAX)>
003 | image <varbinary(MAX)>
003 | image <varbinary(MAX)>
3-Cases -case_id -case_name
case_id | case_name
01 | case one
02 | case two
Need output in dataGridView like this :
contracts_id | subject_contract | case_name | file_data | file_data
001 | name | case one | image | image
002 | name | case two | image | image
003 | name | case one | image | image
- get all images have one contracts_id in one row (if contract 001 have 2 images get them in one row)
I try this :
create proc GET_ALL_CONTRACTS
as
SELECT contracts.[contracts_id]
,[subject_contract]
,[case_name]
,[file_data]
FROM contracts, contracts_files
Contracts INNER join Cases
ON Cases.case_id = Contracts.case_id
where contracts_files.contracts_id = Contracts.contracts_id