Return available rooms depending 2 others tables The 2019 Stack Overflow Developer Survey...
How did passengers keep warm on sail ships?
How to charge AirPods to keep battery healthy?
Why was M87 targeted for the Event Horizon Telescope instead of Sagittarius A*?
Inverse Relationship Between Precision and Recall
Why don't hard Brexiteers insist on a hard border to prevent illegal immigration after Brexit?
Why does the nucleus not repel itself?
Getting crown tickets for Statue of Liberty
How do PCB vias affect signal quality?
Likelihood that a superbug or lethal virus could come from a landfill
"as much details as you can remember"
What to do when moving next to a bird sanctuary with a loosely-domesticated cat?
Will it cause any balance problems to have PCs level up and gain the benefits of a long rest mid-fight?
How can I define good in a religion that claims no moral authority?
Can we generate random numbers using irrational numbers like π and e?
Pokemon Turn Based battle (Python)
Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?
For what reasons would an animal species NOT cross a *horizontal* land bridge?
Can there be female White Walkers?
What could be the right powersource for 15 seconds lifespan disposable giant chainsaw?
Can withdrawing asylum be illegal?
Does adding complexity mean a more secure cipher?
Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?
Kerning for subscripts of sigma?
What information about me do stores get via my credit card?
Return available rooms depending 2 others tables
The 2019 Stack Overflow Developer Survey Results Are InQuery: select all rooms which are not bookedQuery multiple rooms with different conditionals (Adults, Children)How do I perform a query on a dynamic list of tables?MySQL database design to sort and filter air traffic dataUpdate Table data using variables depending on other tablesHeidi SQL 'Cannot close tab with running query'Return a ranking from tables with MySQLselect a value from different tables depending on a conditionReturn count from not direct related tableschecking availability of rooms
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Here my table structure:
___Rooms
|--------|----------|
| ROO_Id | ROO_Name |
|--------|----------|
| 1 | Blue |
| 2 | Red |
| 3 | Yellow |
|--------|----------|
___Rates
|--------|---------------|-------------|-----------|-------------------|---------------|
| RAT_Id | RAT_DateStart | RAT_DateEnd | RAT_Price | RAT_RoomsAffected | RAT_RoomsList |
|--------|---------------|-------------|-----------|-------------------|---------------|
| 90 | 2019-04-01 | 2019-05-01 | 139.00 | all | |
| 91 | 2019-05-01 | 2019-12-31 | 159.00 | list | 1,2 |
| 92 | 2019-05-01 | 2019-12-31 | 129.00 | list | 3 |
|--------|---------------|-------------|-----------|-------------------|---------------|
___Availabilities
|--------|------------|------------|------------|
| AVA_Id | AVA_RoomId | AVA_Status | AVA_Date |
|--------|------------|------------|------------|
| 203 | 1 | Open | 2019-04-01 |
| 204 | 1 | Open | 2019-04-02 |
| 205 | 1 | Open | 2019-04-03 |
| 206 | 1 | Open | 2019-04-04 |
| 207 | 1 | Open | 2019-04-05 |
| 208 | 1 | Close | 2019-04-06 |
| 209 | 1 | Close | 2019-04-07 |
|--------|------------|------------|------------|
Here's a quick description of these 3 tables:
_Rooms
contains informations about the rooms I can rent in my hotel.
___Rates
contains the rate informations I can apply for a special period and for rooms (if RAT_RoomsAffected is set to all it means that the rate can be applied for all the rooms I have in my hotel. If RAT_RoomsAffected is set to list, the rate could be applied only the the rooms id in the RAT_RoomsList field).
___Availabilities
list per day the possibility (Open) to book this room or the no possibility to book a room (Close).
My problem is the following:
I would like to list the rooms that respect the two following conditions:
This rooms should be with the
Open
status (AVA_Status) for the dates a client wants to book in my hotel. For example, from the 2019-04-02 to the 2019-04-04 (2 nights).This rooms should be linked with a rate in
_Rates
table. So depending the client dates of stay I need to loop into this table and find a rate for this period.Finally the rates found should match the
ROO_Id
found in the first step. AROO_Id
could match ifRAT_RoomsAffected = all
or when thisROO_Id
is found into theRAT_RoomsList
list.
The desired output should be this one from the 2019-04-02 to the 2019-04-04:
|--------|----------|-----------|
| ROO_Id | ROO_Name | RAT_Price |
|--------|----------|-----------|
| 1 | Blue | 139.00 |
|--------|----------|-----------|
This is the SQLFiddle to help you:
https://www.db-fiddle.com/f/kPY6FmKw1SZJjTHUbLj5Pe/0
Thanks so much for any help I will receive.
mysql
New contributor
add a comment |
Here my table structure:
___Rooms
|--------|----------|
| ROO_Id | ROO_Name |
|--------|----------|
| 1 | Blue |
| 2 | Red |
| 3 | Yellow |
|--------|----------|
___Rates
|--------|---------------|-------------|-----------|-------------------|---------------|
| RAT_Id | RAT_DateStart | RAT_DateEnd | RAT_Price | RAT_RoomsAffected | RAT_RoomsList |
|--------|---------------|-------------|-----------|-------------------|---------------|
| 90 | 2019-04-01 | 2019-05-01 | 139.00 | all | |
| 91 | 2019-05-01 | 2019-12-31 | 159.00 | list | 1,2 |
| 92 | 2019-05-01 | 2019-12-31 | 129.00 | list | 3 |
|--------|---------------|-------------|-----------|-------------------|---------------|
___Availabilities
|--------|------------|------------|------------|
| AVA_Id | AVA_RoomId | AVA_Status | AVA_Date |
|--------|------------|------------|------------|
| 203 | 1 | Open | 2019-04-01 |
| 204 | 1 | Open | 2019-04-02 |
| 205 | 1 | Open | 2019-04-03 |
| 206 | 1 | Open | 2019-04-04 |
| 207 | 1 | Open | 2019-04-05 |
| 208 | 1 | Close | 2019-04-06 |
| 209 | 1 | Close | 2019-04-07 |
|--------|------------|------------|------------|
Here's a quick description of these 3 tables:
_Rooms
contains informations about the rooms I can rent in my hotel.
___Rates
contains the rate informations I can apply for a special period and for rooms (if RAT_RoomsAffected is set to all it means that the rate can be applied for all the rooms I have in my hotel. If RAT_RoomsAffected is set to list, the rate could be applied only the the rooms id in the RAT_RoomsList field).
___Availabilities
list per day the possibility (Open) to book this room or the no possibility to book a room (Close).
My problem is the following:
I would like to list the rooms that respect the two following conditions:
This rooms should be with the
Open
status (AVA_Status) for the dates a client wants to book in my hotel. For example, from the 2019-04-02 to the 2019-04-04 (2 nights).This rooms should be linked with a rate in
_Rates
table. So depending the client dates of stay I need to loop into this table and find a rate for this period.Finally the rates found should match the
ROO_Id
found in the first step. AROO_Id
could match ifRAT_RoomsAffected = all
or when thisROO_Id
is found into theRAT_RoomsList
list.
The desired output should be this one from the 2019-04-02 to the 2019-04-04:
|--------|----------|-----------|
| ROO_Id | ROO_Name | RAT_Price |
|--------|----------|-----------|
| 1 | Blue | 139.00 |
|--------|----------|-----------|
This is the SQLFiddle to help you:
https://www.db-fiddle.com/f/kPY6FmKw1SZJjTHUbLj5Pe/0
Thanks so much for any help I will receive.
mysql
New contributor
add a comment |
Here my table structure:
___Rooms
|--------|----------|
| ROO_Id | ROO_Name |
|--------|----------|
| 1 | Blue |
| 2 | Red |
| 3 | Yellow |
|--------|----------|
___Rates
|--------|---------------|-------------|-----------|-------------------|---------------|
| RAT_Id | RAT_DateStart | RAT_DateEnd | RAT_Price | RAT_RoomsAffected | RAT_RoomsList |
|--------|---------------|-------------|-----------|-------------------|---------------|
| 90 | 2019-04-01 | 2019-05-01 | 139.00 | all | |
| 91 | 2019-05-01 | 2019-12-31 | 159.00 | list | 1,2 |
| 92 | 2019-05-01 | 2019-12-31 | 129.00 | list | 3 |
|--------|---------------|-------------|-----------|-------------------|---------------|
___Availabilities
|--------|------------|------------|------------|
| AVA_Id | AVA_RoomId | AVA_Status | AVA_Date |
|--------|------------|------------|------------|
| 203 | 1 | Open | 2019-04-01 |
| 204 | 1 | Open | 2019-04-02 |
| 205 | 1 | Open | 2019-04-03 |
| 206 | 1 | Open | 2019-04-04 |
| 207 | 1 | Open | 2019-04-05 |
| 208 | 1 | Close | 2019-04-06 |
| 209 | 1 | Close | 2019-04-07 |
|--------|------------|------------|------------|
Here's a quick description of these 3 tables:
_Rooms
contains informations about the rooms I can rent in my hotel.
___Rates
contains the rate informations I can apply for a special period and for rooms (if RAT_RoomsAffected is set to all it means that the rate can be applied for all the rooms I have in my hotel. If RAT_RoomsAffected is set to list, the rate could be applied only the the rooms id in the RAT_RoomsList field).
___Availabilities
list per day the possibility (Open) to book this room or the no possibility to book a room (Close).
My problem is the following:
I would like to list the rooms that respect the two following conditions:
This rooms should be with the
Open
status (AVA_Status) for the dates a client wants to book in my hotel. For example, from the 2019-04-02 to the 2019-04-04 (2 nights).This rooms should be linked with a rate in
_Rates
table. So depending the client dates of stay I need to loop into this table and find a rate for this period.Finally the rates found should match the
ROO_Id
found in the first step. AROO_Id
could match ifRAT_RoomsAffected = all
or when thisROO_Id
is found into theRAT_RoomsList
list.
The desired output should be this one from the 2019-04-02 to the 2019-04-04:
|--------|----------|-----------|
| ROO_Id | ROO_Name | RAT_Price |
|--------|----------|-----------|
| 1 | Blue | 139.00 |
|--------|----------|-----------|
This is the SQLFiddle to help you:
https://www.db-fiddle.com/f/kPY6FmKw1SZJjTHUbLj5Pe/0
Thanks so much for any help I will receive.
mysql
New contributor
Here my table structure:
___Rooms
|--------|----------|
| ROO_Id | ROO_Name |
|--------|----------|
| 1 | Blue |
| 2 | Red |
| 3 | Yellow |
|--------|----------|
___Rates
|--------|---------------|-------------|-----------|-------------------|---------------|
| RAT_Id | RAT_DateStart | RAT_DateEnd | RAT_Price | RAT_RoomsAffected | RAT_RoomsList |
|--------|---------------|-------------|-----------|-------------------|---------------|
| 90 | 2019-04-01 | 2019-05-01 | 139.00 | all | |
| 91 | 2019-05-01 | 2019-12-31 | 159.00 | list | 1,2 |
| 92 | 2019-05-01 | 2019-12-31 | 129.00 | list | 3 |
|--------|---------------|-------------|-----------|-------------------|---------------|
___Availabilities
|--------|------------|------------|------------|
| AVA_Id | AVA_RoomId | AVA_Status | AVA_Date |
|--------|------------|------------|------------|
| 203 | 1 | Open | 2019-04-01 |
| 204 | 1 | Open | 2019-04-02 |
| 205 | 1 | Open | 2019-04-03 |
| 206 | 1 | Open | 2019-04-04 |
| 207 | 1 | Open | 2019-04-05 |
| 208 | 1 | Close | 2019-04-06 |
| 209 | 1 | Close | 2019-04-07 |
|--------|------------|------------|------------|
Here's a quick description of these 3 tables:
_Rooms
contains informations about the rooms I can rent in my hotel.
___Rates
contains the rate informations I can apply for a special period and for rooms (if RAT_RoomsAffected is set to all it means that the rate can be applied for all the rooms I have in my hotel. If RAT_RoomsAffected is set to list, the rate could be applied only the the rooms id in the RAT_RoomsList field).
___Availabilities
list per day the possibility (Open) to book this room or the no possibility to book a room (Close).
My problem is the following:
I would like to list the rooms that respect the two following conditions:
This rooms should be with the
Open
status (AVA_Status) for the dates a client wants to book in my hotel. For example, from the 2019-04-02 to the 2019-04-04 (2 nights).This rooms should be linked with a rate in
_Rates
table. So depending the client dates of stay I need to loop into this table and find a rate for this period.Finally the rates found should match the
ROO_Id
found in the first step. AROO_Id
could match ifRAT_RoomsAffected = all
or when thisROO_Id
is found into theRAT_RoomsList
list.
The desired output should be this one from the 2019-04-02 to the 2019-04-04:
|--------|----------|-----------|
| ROO_Id | ROO_Name | RAT_Price |
|--------|----------|-----------|
| 1 | Blue | 139.00 |
|--------|----------|-----------|
This is the SQLFiddle to help you:
https://www.db-fiddle.com/f/kPY6FmKw1SZJjTHUbLj5Pe/0
Thanks so much for any help I will receive.
mysql
mysql
New contributor
New contributor
New contributor
asked 6 mins ago
TestyTesty
1
1
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "182"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Testy is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234624%2freturn-available-rooms-depending-2-others-tables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Testy is a new contributor. Be nice, and check out our Code of Conduct.
Testy is a new contributor. Be nice, and check out our Code of Conduct.
Testy is a new contributor. Be nice, and check out our Code of Conduct.
Testy is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Database Administrators Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f234624%2freturn-available-rooms-depending-2-others-tables%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown