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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:10:36+00:00 2026-06-09T15:10:36+00:00

I have tables Tasks- id,name then i have userTasks id , task_id , user_id

  • 0

I have tables

Tasks- id,name

then i have

userTasks id , task_id , user_id

and

User - id , name

Suppose i have 10 tasks in task table and out of those i have 3 tasks in userTask table

I want query like this

Select task.id , task.name , STATUS (if(presentInUserTasks),1,0) FROM whatever

the STATUS word should 1 if that task id is present in usertasks table for that userid otherwise it should be 0

So that i am able to find which of those tasks are alreadu in userTask table

  • 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-09T15:10:38+00:00Added an answer on June 9, 2026 at 3:10 pm

    You’re looking for the EXISTS keyword:

    SELECT tasks.id, tasks.name, 
        IF(EXISTS(SELECT id 
                  FROM userTasks 
                  WHERE userTasks.task_id = tasks.id 
                  AND userTasks.user_id = @that_user_id)
           ,1,0) AS STATUS
    FROM tasks
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose that I have 2 tables: [User] - UserID - Username [Task] - TaskID
We have two tables - Tasks and TasksUsers (users assigned to task). Task has
I have table with data about tasks like Id, Name, Date, WorkerId, VehicleId (and
Suppose that I have users, tasks and each task belongs to a batch. Each
I have the following 3 classes(mapped to sql tables). Places table: Name(key) Address Capacity
I have two tables: projects and tasks. A project consists of tasks. I want
Have 2 tables in Access 2007, both lists of certain tasks to be accomplished.
I have a tasks table with a priority column, which has a unique constraint.
I have a table called TPM_TASKS which contain all tasks, as well as a
My table have data structure like this cate_id task_id date_start date_end other 34 14

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.