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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:45:02+00:00 2026-05-28T04:45:02+00:00

I have three tables…users, user_info, and quota_levels. They look like this: CREATE TABLE users

  • 0

I have three tables…users, user_info, and quota_levels. They look like this:

CREATE TABLE users (
    id INT NOT NULL AUTO_INCREMENT,
    name VARCHAR(31) NOT NULL,
    password VARCHAR(33) NOT NULL,
    PRIMARY KEY (id)
);

CREATE TABLE user_info (
    userID INT UNSIGNED NOT NULL,
    firstName VARCHAR(32),
    lastName VARCHAR(32),
    phone CHAR(14),
    address VARCHAR(128),
    birthdate DATE,
    misc TEXT,
    quotaLevel VARCHAR(32),
    PRIMARY KEY (userID)
);

CREATE TABLE quota_levels (
    quotaLevel VARCHAR(32) NOT NULL,
    quota1 INT NOT NULL,
    quota2 INT NOT NULL,
    PRIMARY KEY (level)
);

Every user will have an entry in the users table, but not necessarily in the user_info table. Each user in the user_info table has a quotaLevel corresponding to the quotaLevel column in the quota_levels table. Possible values for quotaLevel are BRONZE, SILVER, GOLD, and PLATINUM.

I could go into a long explanation of why it is set up this way, but it would be quicker to just say that this structure cannot be changed.

If the user exists, I want to get the quota1 value of their quotaLevel. If the user doesn’t exist, the quota1 value for BRONZE should be returned.

I want to do this with ONE query. Can it be done and how?

  • 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-05-28T04:45:02+00:00Added an answer on May 28, 2026 at 4:45 am
    SELECT u.Name, 
           COALESCE(ql.quota1, (SELECT quota1 FROM quota_level WHERE quotaLevel = 'BRONZE'))
        FROM users u
            LEFT JOIN user_info ui  
                INNER JOIN quota_level ql
                    ON ui.quotaLevel = ql.quotaLevel              
                ON u.id = ui.userID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables like this CREATE TABLE `money`.`categories` ( `ID` bigint(20) unsigned NOT
I have three tables: videos, videos_categories, and categories. The tables look like this: videos:
I have three tables: Campus Building Floor and table structure is looks like this:
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables to define users: USER: user_id (int), username (varchar) USER_METADATA_FIELD: user_metadata_field_id
I have three tables, 1-Users, 2-Softwares, 3-UserSoftwares. if suppose, Users table having 6 user
I have three tables: Users, Groups and GroupsUsers User table: id: 1 username: admin
I have three tables in my Crystal Reports and it looks like this: Property
I have three tables named Item, Event, and Seat, constructed like this: Item Id
I have three tables: users, courses and documents. I would like to upload documents

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.