Senses
只有 only have
to only have or there is only; used to indicate that something or someone is the sole one existing or remaining
只有 only if
Used to introduce a necessary condition, usually followed by 才 or 方 in the next clause to show that a result can only happen under this single condition.
只有 to have to
Used to express a lack of alternatives, meaning to be forced to do something or to have no choice but to do it.