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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:55:50+00:00 2026-06-05T20:55:50+00:00

I have an item table where there is a type column. The values here

  • 0

I have an item table where there is a type column. The values here can be 1, 2, 3, or 0. users have a predefined value, but 0 acts as a global – all users get these items returned.

The main caveat is that an item could be a 3, but also have a 0 record as well, meaning the 3s get one record, the 1s and 2s get the 0 record.

My question is how do i write the query so the 3s don’t also get the 0 record?

  • 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-05T20:55:53+00:00Added an answer on June 5, 2026 at 8:55 pm

    To keep your query simple, you can fetch both records, order them by type, descending, then only take the first one:

    • If there is only a type 3 record, it will be returned,
    • If there is only a type 0 record, it will be returned,
    • If there are both type 3 and type 0 records, the type 3 record will be returned because it will occur first in the result set.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've two master tables Org & Item and then there's an OrgItem table.I have
i have this three tables. Table: Item Columns: ItemID, Title, Content, NoChange (Date) Table:
I have a scheduled_item table where I can schedule animations to be displayed. Once
Suppose I have a table Item (Id int Primary Key, Number INT) having records
In my application I have a generic query that applies to multiple users. There
We have have a table layout with property names in one table, and values
This question can best be asked by example. Say I have a database table
Imagine that we have a website where users can read articles, view photos, watch
Let's say you have three tables named Item, Event, and Seat, constructed as such:
I have three tables filters (id, name) items(item_id, name) items_filters(item_id, filter_id, value_id) values(id, filter_id,

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.