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

  • Home
  • SEARCH
  • 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 9242627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:37:09+00:00 2026-06-18T08:37:09+00:00

I have a table called ‘connections’ with these fields: entry_id user_id connector_id cat_id Lets

  • 0

I have a table called ‘connections’ with these fields:

entry_id
user_id
connector_id
cat_id

Lets put some rows

    | entry_id | user_id | connector_id |cat_id        |
    |:---------|---------|:------------:|:------------:|
    | 1        |       11|     33       | 1
    | 2        |       13|     11       | 2
    | 3        |        9|     11       | 4
    | 4        |       11|     33       | 6
    | 5        |       33|     11       | 11
    | 6        |        9|     11       | 8

Pseudocode
(using connection between id = 11 and oid = 9)

Select cat_id FROM connections c
if cat_id is between 1 and 5 
   where c.connector_id = id OR c.user_id = id
   AND  c.connector_id = oid OR c.user_id = oid
else if cat_id is greater than 5
   where oid = user_id and id = connector_id

In english;
If the cat_id is between 1 and 5, it should select cat_ids from where oid and id are both in connector_id or user_id, it doesn’t matter which order as long as they are in one or the other, but if the cat_id is greater than 5, it should only select cat_ids where oid is the user_id and id is the connector_id.

Result (for connection between id = 11 and oid = 9)

    | cat_id     | 
    |:-----------|
    | 4          |        
    | 8          |  

One more example:
Result (for connection between id = 33 and oid = 11 )

   | cat_id     | 
   |:-----------|
   | 1          |        
   | 6          |  

Please ask if they’re parts that are not clear.

  • 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-18T08:37:11+00:00Added an answer on June 18, 2026 at 8:37 am

    You should be able to accomplish this by just following your if statements logically. Something like:

    Select cat_id FROM connections c
    where 
    (id between 1 and 5 AND (c.connector_id = id OR c.user_id = id)
       AND  (c.connector_id = oid OR c.user_id = oid)) 
    OR id > 5 AND (oid = user_id and id = connector_id)
    

    Note: in agreement with some of the comments – ensure this is what you need to be doing. I made some assumptions about how you intended your logic to be from the pseudo-code, these may be wrong – so please think about it before just copying and pasting. This specifically applies to how you structured your OR / AND in the where clause.

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

Sidebar

Related Questions

I have a table called foo with these fields: - id - type -
i have table called type which contains data family,individual i want in some pages
i have table called users , if i want to delete some user (User
I have table /entity called SaleRecord with fields such as @Entity public class SaleRecord
I have a table called hl7_lock in SQL Server with these columns: hl7_id lock_dtm
I have table called comments with following structure: id | entry_id | date |
Lets say i have table called Orders id qty1 qty2 qty3 ----------------------------------- 1 1
I have table called stats . In am inserting yes or no in the
i have table called as Support, which have a field named Name and contains
I have table called Buttons. Buttons table i have column button_number . Table contain

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.