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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:09:01+00:00 2026-06-04T02:09:01+00:00

I am trying to make a simple reservation system. I have two tables as

  • 0

I am trying to make a simple reservation system.

I have two tables as room_types, and rooms. In rooms, I have a boolean field, showing that if that room is available or not. I want to list room types, where there exist at least one room available for that type. I know I need to use join and count, but I couldn’t put together the whole query. Any help is appreciated.

My schema (trimmed unnecessary fields):

room_types [id, name(varchar), size(int), price(float) ...]
rooms [no (int), type (int) (foreign key room_types(id)), available (bool), ...]
  • 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-04T02:09:02+00:00Added an answer on June 4, 2026 at 2:09 am
    select room_types.id from room_types
        inner join rooms on rooms.room_type = room_types.id and rooms.available = 1
    group by room_types.id
    

    The concept is in there, but I can’t write the query exactly since I do not know your schema. I do hope though that you learn what you need from this and apply it to your own schema.

    select room_types.id, COUNT(rooms.id) from room_types
        left outer join rooms on rooms.room_type = room_types.id and rooms.available = 1
    group by room_types.id
    order by COUNT(rooms.id) desc
    

    With counting (including room types where there may to be available rooms).

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

Sidebar

Related Questions

I am trying to make a simple reservation system. I have a table called
Trying to make something simple in JS. Lets say I have two images, I
Trying to make simple minesweeper game in python, but have one problem. I have
Trying to make a simple client that consumes a web service using RemObjects SDK,
I'm trying to make simple many-to-one association, using NHibernate.. I have class Recruit with
I am trying to make simple regex that will check if a line is
Trying to make simple jQuery function to create a scrollToTop button that fades in
I am trying to make simple app that allows one to compare image to
im trying to make a simple game on cocos2d box2d, its basically got two
I am trying to make a simple AJAX calling in PHP and have a

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.