Delete query with multiple tables and left join

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jesse Jones
    New Member
    • Jan 2011
    • 51

    Delete query with multiple tables and left join

    Can someone please help me with this SQL? I am very ignorant, but am trying to learn! lol

    I am trying to delete the records in tblMinsitries where this criteria is met. This works as a select query, but not as a delete query. Please help!

    Code:
    SELECT *
    FROM tblMinistries LEFT JOIN tblCallLog ON tblMinistries.tblMinistries_ministryID=tblCallLog.tblCallLog_ID
    WHERE (((tblCallLog.tblCallLog_dateStamp)<>tblMinistries.tblMinistries_lastAccessedDate And tblMinistries.tblMinistries_lastAccessedDate Is Not Null)) Or (((tblCallLog.tblCallLog_dateStamp) Is Null And tblMinistries.tblMinistries_lastAccessedDate Is Not Null));
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    More information please.

    What error are you receiving?
    I suspect something about related records?
    You'll need to either find and delete those records first or change the table relationships to allow cascade deletions as-well-as the cascade updates in the enforcement section.


    To confirm this we may need to see the relationships between the involved tables too. You can either type them as a list (for an example, see my post #28 in thread Crosstab on Three tables) or you can do a screen shot and post the cropped down picture ( as I've done in post #8 in Many-to-Many-to-Many Relationship
    Last edited by NeoPa; Oct 28 '12, 12:28 AM. Reason: Answer reset as it wasn't an answer.

    Comment

    • Jesse Jones
      New Member
      • Jan 2011
      • 51

      #3
      Thank you for the help. I have since realized a design modification that would make this much more efficient and not require this query at all.

      Thank you!!!!

      Comment

      Working...