---
title: "SQL-018: Retrieve IMAGE_AFFILIATION collection by image"
summary: Retrieves all IMAGE_AFFILIATION rows for a given IMAGE_SEQ_NUM.
status: draft
owner: <owner>
last_reviewed: 2026-07-24
library: SAIF.Business.Imaging
reference_type: package
---

# SQL-018: Retrieve IMAGE_AFFILIATION collection by image

This statement retrieves all `IMAGE_AFFILIATION` rows associated with a given `IMAGE_SEQ_NUM`. It is executed by `clsImageAffiliationCollection.BeforeRetrieve` to load all affiliations for an image.

## Classification

| Field | Value |
| --- | --- |
| **SQL ID** | SQL-018 |
| **Operation type** | Read |
| **Execution method** | Inline SQL |
| **Database** | Oracle |
| **Schema** | [unqualified]** |
| **Command type** | Text** |
| **Business object** | `clsImageAffiliationCollection` |
| **Criteria property** | `RetrieveSQL` |
| **Lifecycle method** | `BeforeRetrieve` |

## Parameters

| Parameter | Direction | Type | Max length | Description |
| --- | --- | --- | --- | --- |
| `:ImageSeqNum` | Input | [not specified]** | N/A | Foreign key: the image sequence number whose affiliations to retrieve. |

## Tables

| Table | Access | Columns used |
| --- | --- | --- |
| [IMAGE_AFFILIATION](../database-tables.md#image_affiliation) | SELECT | AFFILIATION_IMAGE_SEQ_NUM, CREATE_DATE, CREATE_USER, IMAGE_AFFILIATION_SEQ_NUM, IMAGE_SEQ_NUM |

## Sample SQL

```sql
Select
    IMAGE_AFFILIATION.AFFILIATION_IMAGE_SEQ_NUM as AffiliationImageSeqNum,
    IMAGE_AFFILIATION.CREATE_DATE as CreateDate,
    IMAGE_AFFILIATION.CREATE_USER as CreateUser,
    IMAGE_AFFILIATION.IMAGE_AFFILIATION_SEQ_NUM as ImageAffiliationSeqNum,
    IMAGE_AFFILIATION.IMAGE_SEQ_NUM as ImageSeqNum
From IMAGE_AFFILIATION
Where IMAGE_AFFILIATION.IMAGE_SEQ_NUM = :ImageSeqNum
```

## Operations and processes
- [Image affiliation](../operations/image-affiliation.md)

> **Note:** Statements marked with `**` could not be confirmed; treat as unknown until verified.

## Sources
- `Business\SAIF.Business.Imaging\clsImageAffiliationCollection.vb`
