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 7815769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:37:29+00:00 2026-06-02T05:37:29+00:00

Schema I have 3 tables with the following columns: tblClients [ClientID, ClientName, Client Contact]

  • 0

Schema

I have 3 tables with the following columns:

tblClients [ClientID, ClientName, Client Contact]
tblEvents [EventID, EventName]
tblEventBook [EventBookID, EventID, ClientID]
  • tblEventBook EventID matches tblEvents EventID
  • tblEventBook ClientID matches tblClients ClientID

I have two parameters: @useEventID and @useClientID

I would like to retrieve all rows from tblClient where tblEventBook does not equal useEventID and useClientID.

I tried to use the below, but it does not work:

SELECT * 
FROM tblClients 
WHERE tblEventBook.EventID <> @useEventID 
  AND tblEventBook.ClientID <> @useClientID

Sample Data:

tblEventBook

EventBookID EventID ClientID 
1           1          1 
2           2          2
3           3          1
4           4          2

tblClients

ClientID ClientName  ClientContact
1        TestNameA   12345
2        TestNameB   54321

tblEvents

EventID EventName
1       TestEventA
2       TestEventB
3       TestEventC
4       TestEventD
5       TestEventE

Required results

I need to get the below results when I use:

  1. @useClientID = 1, @useEventID = 1

    It should return ClientID 2

  2. @useClientID = 2, @useEventID = 1

    It should return ClientID 1 and 2

  3. @useClientID = 2, @useEventID = 2

    It should return ClientID 1

  4. @useClientID = 5, @useEventID = 2

    It should return ClientID 1 and 2

  • 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-06-02T05:37:30+00:00Added an answer on June 2, 2026 at 5:37 am

    This solution will exclude all tblClients with @useClientID and related tblEventBook that match @useEventID:

    select * from tblClients c
    where c.ClientID <> @useClientID
    and not exists(select 1 from tblEventBook where ClientID=c.ClientID and EventID=@useEventID)
    

    But from your description I also see a slightly difference possibility, where we only exclude tblClients if a related tblEventBook record exists having @useClientID and @useEventID:

    select * from tblClients c
    where not exists(
        select 1 from tblEventBook 
        where ClientID=c.ClientID 
        and EventID=@useEventID
        and ClientID=@useClientID
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following schema.yml: JosJeventsVevdetail: connection: doctrine tableName: jos_jevents_vevdetail columns: evdet_id: type: integer(4)
I have no control over database schema and have the following (simplified) table structure:
I have the following pseudo-SQL schema: table flight id int primary key date timestamp
I have a bunch of coordinates in my table grid with the following schema
I have two tables with identical schema. Let's name them TestTable and TestTableTemp .
I have two tables in my database schema that represent an entity having a
I have two tables userdetails and blog question The schema is UserDetails: connection: doctrine
I have two tables names book_list and book_category . Schema is like below: book_list
Schema: Users ID Name Password Address ID Street UserID Both tables have an ID
I have the following SQL statement: USE ws_results_db_2011_09_11_09_06_24;SELECT table_name FROM INFORMATION_SCHEMA.Tables WHERE table_name like

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.