Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:54:11+00:00 2026-05-27T06:54:11+00:00

I’d like to write a delete script that deletes rows out of the bridge

  • 0

I’d like to write a delete script that deletes rows out of the bridge table (acucore_securitypermission). Right now, this SELECT query (that will be the rows I’d like to delete) doesn’t work. I get red underlines on the line containing the “NOT EXISTS”. The only difference from the first and second snippet is the SELECT * vs. DELETE. Also, if you have some improvements that I can make to my delete to make it cleaner (without repetition), I’m always looking for tips.

SELECT script that doesn’t work:

SELECT groupname
FROM dbo.acucore_securitycontainer
INNER JOIN dbo.acucore_securitypermission ON dbo.acucore_securitycontainer.esid = dbo.acucore_securitypermission.esid
INNER JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
WHERE containername LIKE '%:UI.Web.AccessioningDashboard'
AND groupname NOT EXISTS -- <-------- I get red error underlines here!
(
    SELECT 
        groupname
    FROM dbo.acucore_securitycontainer
    INNER JOIN dbo.acucore_securitypermission ON dbo.acucore_securitycontainer.esid = dbo.acucore_securitypermission.esid
    INNER JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
    WHERE containername = 'UI.Web.AccessioningDashboard'
    AND permissions = 1
)

DELETE script that I want to eventually run:

DELETE FROM dbo.acucore_securitycontainer
INNER JOIN dbo.acucore_securitypermission ON dbo.acucore_securitycontainer.esid = dbo.acucore_securitypermission.esid
INNER JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
WHERE containername LIKE '%:UI.Web.AccessioningDashboard'
AND groupname NOT EXISTS 
(
    SELECT 
        groupname
    FROM dbo.acucore_securitycontainer
    INNER JOIN dbo.acucore_securitypermission ON dbo.acucore_securitycontainer.esid = dbo.acucore_securitypermission.esid
    INNER JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
    WHERE containername = 'UI.Web.AccessioningDashboard'
    AND permissions = 1
)

=====================

UPDATE 12/1/2011 @ 3:05pm

Okay, to finish this, I want to delete from the acucore_securitypermission bridge table. There are two keys in this table. How can I finish this? The SELECT query is the WHERE part containing the two key values.

DELETE FROM dbo.acucore_securitypermission
 .... ????

SELECT 
    dbo.acucore_securitypermission.entityid,
    dbo.acucore_securitypermission.esid
FROM dbo.acucore_securitycontainer
INNER JOIN dbo.acucore_securitypermission ON dbo.acucore_securitycontainer.esid = dbo.acucore_securitypermission.esid
INNER JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
WHERE containername LIKE '%:UI.Web.AccessioningDashboard'
AND groupname NOT IN
(
    SELECT 
        groupname
    FROM dbo.acucore_securitycontainer
    INNER JOIN dbo.acucore_securitypermission ON dbo.acucore_securitycontainer.esid = dbo.acucore_securitypermission.esid
    INNER JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
    WHERE containername = 'UI.Web.AccessioningDashboard'
    AND permissions = 1
)

==========

Final Answer:

DELETE FROM dbo.acucore_securitypermission
WHERE 
    'ENTITYID:' + cast(dbo.acucore_securitypermission.entityid as VARCHAR(64)) + '|' 
    + 'ESID:' + cast(dbo.acucore_securitypermission.esid as VARCHAR(64)) IN
(
    SELECT 
    --groupname,
    --containername,
    --dbo.acucore_securitypermission.esid ,
    --dbo.acucore_securitypermission.entityid ,
    --dbo.acucore_securitypermission.permissions        
        'ENTITYID:' + cast(dbo.acucore_securitypermission.entityid as VARCHAR(64)) + '|' 
        + 'ESID:' + cast(dbo.acucore_securitypermission.esid as VARCHAR(64))
    FROM dbo.acucore_securitypermission
    JOIN dbo.acucore_securitycontainer ON dbo.acucore_securitypermission.esid = dbo.acucore_securitycontainer.esid
    JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
    WHERE containername LIKE 'S:UI.Web.AccessioningDashboard'
    AND groupname NOT IN
    (
        SELECT 
            CASE WHEN groupname IN ('Accessioning', 'Screening', 'Positive Certify', 'Negative Certify', 'Confirmation') THEN 'Saliva: ' + groupname ELSE groupname END
        FROM dbo.acucore_securitypermission
        JOIN dbo.acucore_securitycontainer ON dbo.acucore_securitypermission.esid = dbo.acucore_securitycontainer.esid
        JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
        WHERE containername = 'UI.Web.AccessioningDashboard'
        AND permissions = 1
    )
)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:54:12+00:00Added an answer on May 27, 2026 at 6:54 am

    Try using “NOT IN” instead of “NOT EXISTS”.

    Edit 12/01/2011 15:24

    For the delete, you could verify the existence of both keys by converting them to a varchar and then concatenating them into a single string. That would allow you to make the “IN” work.

    DELETE FROM dbo.acucore_securitypermission
    WHERE cast(entityid as VARCHAR(64)) + '-' + cast(esid as VARCHAR(64)) IN
    (
        SELECT cast(entityid as VARCHAR(64)) + '-' + cast(esid as VARCHAR(64))
        FROM dbo.acucore_securitycontainer
        INNER JOIN dbo.acucore_securitypermission ON dbo.acucore_securitycontainer.esid = dbo.acucore_securitypermission.esid
        INNER JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
        WHERE containername LIKE '%:UI.Web.AccessioningDashboard'
        AND groupname NOT IN
        (
            SELECT groupname
            FROM dbo.acucore_securitycontainer
            INNER JOIN dbo.acucore_securitypermission ON dbo.acucore_securitycontainer.esid = dbo.acucore_securitypermission.esid
            INNER JOIN dbo.acucore_securitygroup ON dbo.acucore_securitypermission.entityid = dbo.acucore_securitygroup.entityid
            WHERE containername = 'UI.Web.AccessioningDashboard'
            AND permissions = 1
        )
    )
    

    Like a camel, it’s ugly but it should get the job done.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.