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

  • Home
  • SEARCH
  • 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 9240527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:12:17+00:00 2026-06-18T08:12:17+00:00

Bellow is my rooms mysql table. (This is example table i have created to

  • 0

Bellow is my “rooms” mysql table. (This is example table i have created to show here.)

enter image description here

I want to show low cost rooms in case multiple room bookings. Ex: User have select two room, 1 adult in first room and 2 adults in second room. Now my result should come as below

enter image description here

My Query is : SELECT * FROM rooms WHERE hotel_code=”100″ GROUP BY adult+child Order by cost ASC

It is not working. I am not able to get the expected result with this query. Please let me know the solution for this.

  • 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-18T08:12:18+00:00Added an answer on June 18, 2026 at 8:12 am

    Try this:

    SELECT  r.*
    FROM Rooms r
    INNER JOIN
    (
      SELECT 
        adult, child, MIN(Cost) MinCost
      FROM Rooms
      WHERE hotel_code = 100
      GROUP BY  adult, child
    ) m ON r.adult = m.adult AND r.child = m.child
      AND r.cost = m.mincost
    ORDER BY r.id
    LIMIT 2;
    

    SQL Fiddle Demo

    This will give you:

    | ID | HOTEL_CODE |    ROOM_TYPE | ADULT | CHILD | COST |
    ---------------------------------------------------------
    |  2 |        100 | Single Delux |     1 |     0 |   20 |
    |  3 |        100 | Twin Stadard |     2 |     0 |   25 |
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with a Ajax.BeginForm on each row. This works good to
I have the below jquery function $(function(){ $(select#rooms).change(function(){ $.getJSON(/admin/select.php,{id: $(this).val(), ajax: 'true'}, function(j){ var
I have created a menu but cannot solve this issue so I am hoping
I have a query using LINQ-to-SQL. It queries an underlying database table Rooms. It
I am doing project of hotel booking system in php and mysql I created
I have 4 Tables (listed bellow) and need: get last 10 Chats from Room
I have created a room, actually rectangular with two windows and one door. I
I want to query the table below as to return the titles of the
I have a problem in writing the sql to get the available rooms from
i have datagrid(see bellow) there is columns with date time how i can make

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.