List:General Discussion« Previous MessageNext Message »
From:Raul Andres Duque Date:February 26 2007 1:58pm
Subject:Re: problems with a select
View as plain text  
I'm spanish speaker too .. but I write it in english for everyone can read 

The version 5 implements subqueries. You can do something like:

SELECT id_room
FROM rooms
WHERE id_room NOT IN (SELECT id_room FROM reservations WHERE date = 


Bogotá, Colombia

----- Original Message ----- 
From: "Yo Mismo" <d_alonso1@stripped>
To: <mysql@stripped>
Sent: Monday, February 26, 2007 8:41 AM
Subject: problems with a select

First at all, i`m spanish so please, apologize for my english
Hello to everybody, i`m a newby with mysql and i have a problem with a 
I`m making a database for a hostel
I have 2 tables for reservations, one is called rooms  and have 2 fields 
(id_room, tipo)and the other one is ocupation with 3 colums(id_reservation, 
date and id_room)
I`m using innodb database
I insert a register on the ocupation table for each day of the reservations, 
with the id_room and the id_reservation
I wanna mean, if u make a reservation for the 22-3-2007 to 24-3-2007 i will 
do that

  rooms table
id_reservation        date            id_room
     0001            2007-03-22        101
     0001            2007-03-23        101
     0001            2007-03-24        101

I know must there are a lot of better ways to do it, but i think is the 
simplest one
Now, my problem with the query is when i need to know for a especific date, 
witch rooms are avaliable
I wanna mean, if i try to check for the 22-03-2007 the query must return me 
all the rooms except the 101
Using SQL i can do it with a minus sentence, but the mysql version i`m 
using(5.0.24a) cant support it
Have anyone any idea?
Thanks, and please, forgive my english

problems with a selectYo Mismo26 Feb
  • Re: problems with a selectRaul Andres Duque26 Feb