how can I join from bsbsubscriptionhistorystatus to bsbbillingaccount
You can usually join bsbsubscriptionhistorystatus to bsbbillingaccount by
following the shared key that links a subscription history record to its
billing account, then joining on that key in SQL. In practice, that means
using an INNER JOIN or LEFT JOIN with the matching ID/foreign-key column
between the two tables.
Typical pattern
If bsbsubscriptionhistorystatus has a billing account ID column, the query
often looks like this:
sql
SELECT shs.*, ba.*
FROM bsbsubscriptionhistorystatus shs
JOIN bsbbillingaccount ba
ON shs.bsbbillingaccountid = ba.id;
The exact column names may differ, but the logic is the same: FROM picks the
first table, JOIN adds the second table, and ON defines the matching key.
If you need all history rows
If you want every subscription-history row even when a billing account is
missing, use a LEFT JOIN instead:
sql
SELECT shs.*, ba.*
FROM bsbsubscriptionhistorystatus shs
LEFT JOIN bsbbillingaccount ba
ON shs.bsbbillingaccountid = ba.id;
That keeps the history row and fills billing-account columns with NULL when
no match exists.
If you are unsure of the key
Look for columns like billingaccountid, bsbbillingaccountid, accountid,
or subscriptionid in the history table, then confirm which one references
bsbbillingaccount. If you paste the column names from both tables, I can
give you the exact join.