If I have a table containing some data such as:
| ID | some_field1 |
|---|---|
| 0 | this is a default row with default configuration |
| 1 | user configured this field |
Would SELECT whatever FROM table WHERE id=? OR id=0 LIMIT 1; always return the configured row first unless it doesn't exist?
Additionally is there a way that could check if some_field1 is configured independently of other fields without writing all the default values? Say id1 has some_field1 as null but some_field2 configured to something custom, this query would return null instead of the default unless I use the DEFAULT VALUE in the schema creation (and keep that up to date with the row in the database).
I know it could be implemented in the program logic fairly easily but I was wondering if there is a one query solution in SQL itself.
ORDER BYto get the rows of a table in a certain order. Every other order is a coincidence.