473,396 Members | 1,784 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Make two query in too one

I have two SQL query that I would like to make in to one, if possible

Here is the first one: (Query4)
SELECT rooms.DESCRIPTIO, rooms.ID, bookings1.DATE
FROM bookings1 INNER JOIN rooms ON bookings1.ROOMID = rooms.ID
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.ID = Query4.ROOMID
WHERE (((Query4.ROOMID) Is Null));

Is it possible to make one query of this two?
With the same result.
Jul 20 '05 #1
3 2772
> 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.
http://www.aspfaq.com/5006

--
David Portas
SQL Server MVP
--
Jul 20 '05 #2
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

"David Portas" <RE****************************@acm.org> wrote in message news:<Ke********************@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.
http://www.aspfaq.com/5006

Jul 20 '05 #3
Bert Boye (sa***@a-o.biz) writes:
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, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PMB | last post by:
Thank you in advance for any and all assistance. I'm trying to use a make table query to pull the last transactionID, so I can use an append query to reset the transactionID to the next...
4
by: Oreo Bomb | last post by:
I have a secured database that contains a Read-Only group. This group has permissions to view reports, but cannot add, edit, or delete any DB objects. One of the reports the group needs access to...
7
by: Nicolae Fieraru | last post by:
I have two tables, they contain: Table1: ID1, Name1, Address1, Purchase1 Table2: ID2, Name2, Address2, Purchase2 I need a query which creates Table3 with content from Table1 and Table2. The...
2
by: Kathy Krizl | last post by:
I'm probably doing something stupid, but I have a make table query. One of the tables I reference has some check box fields in it. Their Data Type is Yes/No, their field property format is Yes/No,...
24
by: Bob Alston | last post by:
Anyone know a way to make all access to a linked table, in another Access MDB, read only? I really don't want all the hassle of implementing full access security. I can't do this at the server...
1
by: danijela.simunovic | last post by:
Hi! Is there a way that when I run a "make table query" and an "append query" that i won't be asked those 2 or 3 questions from access like :"you are about to run a make table...","the existing...
4
by: ken | last post by:
Hi, I use this command to run a make table query without opening it... CurrentDb.Execute "make table query name" Access tells me that it can't execute a select query...? Its a make table query...
2
by: Robert | last post by:
I am trying to give the user dynamic search capabilities to select almost any record in the database from criteria they select. Everything seems to work except when I open the display form to...
3
by: Robertf987 | last post by:
Hi, I'm a bit stuck with an access database. I'm using access 2000 if that's any help. Right, it's 3:40am right now and I'm rather tired, but I *hope* this makes sense. I have a table which...
27
by: MLH | last post by:
How can I turn the following into a make-table query? SELECT & " " & AS Recipient FROM tblVehicleJobs INNER JOIN tblAddnlOwnrs ON tblVehicleJobs.VehicleJobID = tblAddnlOwnrs.VehicleJobID WHERE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.