Let's say I want to join on 2 tables, one is filled like this.
| Category |
|-----------|
| id | name |
|----|------|
| 1 | Foo |
| 2 | Bar |
| 3 | Baz |
The other like this:
| Page |
|-----------|
| id | cat |
|----|------|
| 1 | 0 |
| 2 | 1 |
| 3 | 3 |
As you can see cat 0 in the Page
table is not present in the Category
table. Our system is unfortunately like this and I can't add the category with id 0
to the Category
table, due to other code.
Now comes the one million dollar question: Is it possible to join category.id
on page.cat
and set an if statement when page.cat
equals 0
to show the category name as Default
?