61 lines
2.2 KiB
Markdown
61 lines
2.2 KiB
Markdown
# Processes by material 2a
|
|
Analysis generated on: 4/2/2025 10:06:13 AM
|
|
---
|
|
## SQL Statement
|
|
```sql
|
|
DELETE [RMSFILES#_IEMUP1A0].ACTIV, [Process by material].*
|
|
FROM [Process by material] LEFT JOIN [RMSFILES#_IEMUP1A0] ON [Process by material].prt = [RMSFILES#_IEMUP1A0].PRDNO
|
|
WHERE ((([RMSFILES#_IEMUP1A0].ACTIV)="0"));
|
|
|
|
```
|
|
## Dependencies
|
|
- [[Tables/[RMSFILES__IEMUP1A0]]]
|
|
## Parameters
|
|
- *None*
|
|
## What it does
|
|
**SQL Code Explanation**
|
|
==========================
|
|
|
|
### Description
|
|
|
|
This SQL code deletes rows from the `[Process by material]` table where a matching row exists in the `[RMSFILES#_IEMUP1A0]` table and the `PRDNO` matches, but the corresponding record is inactive (`ACTIV = "0"`).
|
|
|
|
### Code Breakdown
|
|
|
|
#### Table Names and Aliases
|
|
|
|
* `[Process by material]`: The table from which rows will be deleted.
|
|
* `[RMSFILES#_IEMUP1A0]`: The table used for join operations. Its alias is `_IEMUP1A0`.
|
|
* `.ACTIV` and `.PRDNO` are columns in the `[Process by material]` and `[RMSFILES#_IEMUP1A0]` tables, respectively.
|
|
|
|
#### Join Operation
|
|
|
|
The code performs a `LEFT JOIN` operation between the two tables on the condition that their corresponding `PRDNO` values match:
|
|
|
|
```sql
|
|
FROM [Process by material] LEFT JOIN [RMSFILES#_IEMUP1A0] ON [Process by material].prt = [RMSFILES#_IEMUP1A0].PRDNO
|
|
```
|
|
|
|
The `.prt` column in the `[Process by material]` table is matched with the `.PRDNO` column in the `[RMSFILES#_IEMUP1A0]` table.
|
|
|
|
#### Delete Condition
|
|
|
|
Rows are deleted from the `[Process by material]` table where an inactive record exists in the `[RMSFILES#_IEMUP1A0]` table:
|
|
|
|
```sql
|
|
WHERE ((([RMSFILES#_IEMUP1A0].ACTIV)="0"));
|
|
```
|
|
|
|
This condition filters rows based on the value of `.ACTIV` in the `[RMSFILES#_IEMUP1A0]` table. If `ACTIV` equals `"0"`, it means the record is inactive, and its corresponding row should be deleted from the `[Process by material]` table.
|
|
|
|
### SQL Syntax
|
|
|
|
The syntax for this query uses the following features:
|
|
|
|
* Table aliases (`[RMSFILES#_IEMUP1A0].*`) allow for easier naming of columns.
|
|
* `LEFT JOIN` ensures that all rows in the left table are included, even if there is no match in the right table.
|
|
|
|
### SQL Usage
|
|
|
|
This query is typically used to remove records from a production database where an inactive record exists in another table.
|