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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:55:38+00:00 2026-06-16T04:55:38+00:00

Table 1 – USERS : user_id | email_id | type ————————————— 000121 | test_20@test.com

  • 0

Table 1 – USERS:

user_id | email_id         | type
---------------------------------------
000121  | test_20@test.com | EXT
000125  | best_21@test.com | LOT
000128  | lite_21@test.com | EXT

Table 2- HISTORY:

old_user_id | new_user_id | another_type
----------------------------------------
000128      | 000121      | INIT  

I have email_id in hand say test_20@test.com, I want to do a join query that should return 1, if the user_email_id I had, is in USERS table with EXT as TYPE and in HISTORY table with ANOTHER_TYPE as INIT;

I have a query with a single join for old_user_id .

IF EXISTS (SELECT 1 FROM   history cmr (nolock) 
                  INNER JOIN users au (nolock) 
                          ON au.user_id = cmr.old_user_id 
                  AND cmr.another_type = 'INIT  'AND au.type = 'EXT' 
                   AND au.email_id = 'test_20@test.com') 
  SELECT 1 ELSE   SELECT 0 

When I query test_20@test.com or test_20@test.com, it should return 1. I want to add the join condition for new_user_id also .

So either user (old or new) should be EXT in USERS, and should be INIT in HISTORY

Thanks in advance

  • 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-16T04:55:40+00:00Added an answer on June 16, 2026 at 4:55 am
    IF EXISTS 
    (
    SELECT * FROM   history cmr 
    Left JOIN users au  ON au.user_id = cmr.old_user_id  AND cmr.another_type = 'INIT  'AND au.type = 'EXT'  AND au.email_id = 'test_20@test.com' 
    Left JOIN users au2  ON au2.user_id = cmr.new_user_id  AND cmr.another_type = 'INIT  'AND au2.type = 'EXT'  AND au2.email_id = 'test_20@test.com'
    Where (au.user_id is NOT NULL) or (au2.user_id is NOT NULL)
    )
    SELECT 1 ELSE   SELECT 0 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

table: user | user_Id | my_threads | | 100 | 200:1, 201:2, 217:4 |
table: USERS | id | name | city_id | | 1 | jonh |
Table: CREATE TABLE `test` ( `uid` int(11) unsigned NOT NULL AUTO_INCREMENT, `rating` smallint(5) unsigned
Table - user_feed column name - date_n_time (type - datetime) How do I write
table **salesrule_coupon**: fileds as the following: coupon_id code 1 Registered_send_5 2 test table: salesrule_coupon_usage
Table 1 - users id username items 1 Paul 1(0020);2(0001); Table 2 - items
Table 1 Mail Special Quote (Y/N) g@hotmail.com Blank s@ho.com Blank sss@j.com Blank Table 2
Table structure: users: uid, name friendships: uid1, uid2 game_membership: gid, uid basically I'm trying
Table defintion is create table users ( serial_no integer PRIMARY KEY DEFAULT nextval('serial'), uid
TABLE users_community_relations list_id int user_id int dest_user_id int 1 10 20 2 10 24

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.