I’m trying to get the MIN value from both tables (one return value).
Following mysql structure + data:
table_master
`ID` (Unique) | `Amount`
1 | 5.8
2 | 22.1
3 | 44.22
table_variants
`table_master_ID` | `Amount`
1 | 4.11
1 | 5.12
1 |
1 |
2 | 9.22
3 |
With this query:
SELECT table_master.Amount, table_variants.Amount
FROM table_master
LEFT JOIN table_variants ON table_master.ID = table_variants.table_master_ID
WHERE table_master.ID = 1
I get something like this:
5.8 | 4.11
5.8 |
5.8 | 5.12
...
Now I need the MIN Amount value of both tables.
ID of table_master is unique, data in table_variants is optional.
How can I do this? I was trying MIN() with CASE() but without success.
Any hints?
TIA!
MySQL UNION Syntax
MySQL LEAST Function