Unix Technical Forum

problems with a select

This is a discussion on problems with a select within the MySQL General forum forums, part of the MySQL category; --> First at all, i`m spanish so please, apologize for my english Hello to everybody, i`m a newby with mysql ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:52 AM
Yo Mismo
 
Posts: n/a
Default 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 select
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 05:52 AM
Raul Andres Duque
 
Posts: n/a
Default Re: problems with a select

I'm spanish speaker too .. but I write it in english for everyone can read
it.

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 =
'22-03-07');

Regards,

RAUL DUQUE
Bogotá, Colombia

----- Original Message -----
From: "Yo Mismo" <d_alonso1@teleline.es>
To: <mysql@lists.mysql.com>
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
select
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


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:25 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com