JOIN correctly no matter which end is linked Suppose I have the following two tables: SupportTicket and Link. I also have other tables that Link can connect between. I've created these tables and a hypothetical third table that can be linked to on SQL Fiddle.

Let's suppose I want to count the number of support tickets submitted for technical support related reasons, here is my query:

SELECT
  st.Submitting_User,
  COUNT(l.Link_ID) AS [Count]
FROM 
  SupportTicket st
  JOIN Link l
    ON st.SupportTicket_ID = l.Entity_ID1
WHERE 
  l.Link_ID LIKE 'CAS%'
  AND st.Type = 'Tech Support'
  AND st.Date_Submitted BETWEEN '20140201' AND CURRENT_TIMESTAMP
GROUP BY
  st.Submitting_User, st.Submitting_Department
ORDER BY
  st.Submitting_User


Note that this query is already set up and runs on SQL Fiddle (where you can also see the table structures, etc.).

Here's the problem: the SupportTicket can be on either end of the link. Currently this only counts those where the SupportTicket is on the first link end (Entity_ID1). This should also count it when the SupportTicket is on the second link end (Entity_ID2). How do I fix this?
An OR appears to work fine in your fiddle example.

SELECT
  st.Submitting_User,
  COUNT(l.Link_ID) AS [Count]
FROM 
  SupportTicket st
  JOIN Link l
    ON st.SupportTicket_ID = l.Entity_ID1
    OR st.SupportTicket_ID = l.Entity_ID2
WHERE 
  l.Link_ID LIKE 'CAS%'
  AND st.Type = 'Tech Support'
  AND st.Date_Submitted BETWEEN '20140201' AND CURRENT_TIMESTAMP
GROUP BY
  st.Submitting_User, st.Submitting_Department
ORDER BY
  st.Submitting_User