Answers.Body: <p>select c.id from civicrm_case c left join civicrm_case_contact cc on cc.case_id = c.id where cc.contact_id is null</p>
  <p>then</p>
  <p>insert into civicrm_case_contact (case_id, contact_id) values (1,2)</p>
  <p>where 1 and 2 are the real numbers</p>
  <hr />
  <p>OR it is possible with search kit:</p>
  <p><a href="https://i.sstatic.net/i0z1p.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/i0z1p.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-11T19:05:04.243Z
Answers.Text: indeed. that is where I was heading but in the interest of the wider group of civicrm users I was wanting to confirm if there was a UI approach, and if not, and if there should be, then we might take a look at what changes would be needed to make this viable.
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-11T19:19:12.300Z
Answers.Text: You might be able to do it with search kit, but this situation shouldn't happen, so I'd be more interested in figuring out why the foreign keys allow it and what to do about that.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-12T05:03:11.387Z
Answers.Text: it is possible these were created in webform hence the 'how can it be created with no case contact' may not be a pure civi question
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-13T03:47:34.823Z
Answers.Text: Or maybe "permanently deleted" contacts creating orphan cases, but if so, then that seems an issue with foreign keys in the database.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-04-11T04:23:24.263Z
Answers.LastActivityDate: 2023-05-06T15:17:26.967Z
Answers.LastEditDate: 2023-05-06T15:17:26.967Z
Answers.UserDisplayName: Demerit
Body: <p>Title kind of says it. I found some Cases with no Case Contact in the db. Tried Find Case and Case Reports etc but not sure I can see a way, even when knowing the Case ID, that I can find the problem Case (and hopefully also 'fix' it)</p>
  <p>I know I can probably resolve this in the db, but ideally I shouldn't have to.</p>
  <p>If i know the Case ID then perhaps API Explorer will let me assign a new Case Contact. But first I need to be able to tell there are some problem Cases.</p>
  
Tags: <civicase>
Title: How can I find CiviCases that have no Case Contact via the CiviCRM UI
ThreadText: # How can I find CiviCases that have no Case Contact via the CiviCRM UI
  
  (Asked by: username_0 on 2022-04-11)
  
  Title kind of says it. I found some Cases with no Case Contact in the db. Tried Find Case and Case Reports etc but not sure I can see a way, even when knowing the Case ID, that I can find the problem Case (and hopefully also 'fix' it)
  
  I know I can probably resolve this in the db, but ideally I shouldn't have to.
  
  If i know the Case ID then perhaps API Explorer will let me assign a new Case Contact. But first I need to be able to tell there are some problem Cases.
  
  **Tags:** civicase
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-04-11. Score: 1
  
  select c.id from civicrm\_case c left join civicrm\_case\_contact cc on cc.case\_id = c.id where cc.contact\_id is null
  
  then
  
  insert into civicrm\_case\_contact (case\_id, contact\_id) values (1,2)
  
  where 1 and 2 are the real numbers
  
  ---
  
  OR it is possible with search kit:
  
  [![enter image description here](https://i.sstatic.net/i0z1p.png)](https://i.sstatic.net/i0z1p.png)
  
  > **Comments:**
  > **username_0**: indeed. that is where I was heading but in the interest of the wider group of civicrm users I was wanting to confirm if there was a UI approach, and if not, and if there should be, then we might take a look at what changes would be needed to make this viable.  
  > **username_1**: You might be able to do it with search kit, but this situation shouldn't happen, so I'd be more interested in figuring out why the foreign keys allow it and what to do about that.  
  > **username_0**: it is possible these were created in webform hence the 'how can it be created with no case contact' may not be a pure civi question  
  > **username_1**: Or maybe "permanently deleted" contacts creating orphan cases, but if so, then that seems an issue with foreign keys in the database.  
  
  ---
  
  