Please excuse me, I think I posted in a wrong group :)
The first query gives me a list of booked rooms and the second on a
list of available room.
Let's say I have 4 rooms:
1. Standard
2. Deluxe
3. Super deluxe
4. Suit
Query 1 give me the booked date from 4/3/2004 to 4/9/2004.
RoomID Date
1 4/1/2004
1 4/2/2004
1 4/3/2004
1 4/4/2004
1 4/5/2004
2 4/4/2004
2 4/5/2004
Query 2 shows available room.
3 Deluxe
4 Suit
I have two tables.
1. Bookings1 with fields roomid and date booked
2. Rooms with two fields RoomID and description
Here is the first one: (Query4)
SELECT rooms.DESCRIPTIO, rooms. ROOMID, bookings1.DATE
FROM bookings1 INNER JOIN rooms ON bookings1.ROOMID = rooms. ROOMID
WHERE (((bookings1.DATE) Between #4/3/2004# And #4/9/2004#));
And the second one:
SELECT rooms.ID, rooms.DESCRIPTIO, Query4.ROOMID
FROM rooms LEFT JOIN Query4 ON rooms. ROOMID = Query4.ROOMID
WHERE (((Query4.ROOMID) Is Null));
I really appreciate any help with this and sorry again for posting in
the wrong group;)
Bert
[quoted text, click to view] "David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message news:<Ke6dnR318oYUuN_dRVn-hA@giganews.com>...
> > Is it possible to make one query of this two?
> > With the same result.
>
> Please show an example of the result you want. The first query has columns
> (descriptio, id, date) and the second one has (id, descriptio, roomid).
> Possibly a UNION is what you are looking for but this requires that the
> columns are of compatible data-types.
>
> Is this a SQLServer question? The date format you used isn't valid in TSQL.
>
> It would help make your requirement clearer if you could post DDL and sample
> data.
Bert Boye (sales@a-o.biz) writes:
[quoted text, click to view] > I have two tables.
> 1. Bookings1 with fields roomid and date booked
> 2. Rooms with two fields RoomID and description
>
> Here is the first one: (Query4)
> SELECT rooms.DESCRIPTIO, rooms. ROOMID, bookings1.DATE
> FROM bookings1 INNER JOIN rooms ON bookings1.ROOMID = rooms. ROOMID
> WHERE (((bookings1.DATE) Between #4/3/2004# And #4/9/2004#));
>
> And the second one:
> SELECT rooms.ID, rooms.DESCRIPTIO, Query4.ROOMID
> FROM rooms LEFT JOIN Query4 ON rooms. ROOMID = Query4.ROOMID
> WHERE (((Query4.ROOMID) Is Null));
>
> I really appreciate any help with this and sorry again for posting in
> the wrong group;)
A standard advice when we don't understand what is being asked for
(and I don't in this case) is that you should post:
o CREATE TABLE statements for the tables involved.
o INSERT statements with sample data.
o The desired output from the sample data.
You are saying that you want to make one query out of two. However, I
have no idea on how you want to combine them.
Of course, if you are using Access, you should post to
comp.databases.ms-access instead. However, the advice about CREATE
TABLE etc still applies.
--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se
Books Online for SQL Server SP3 at