|
Home > Archive > microsoft.public.cert.mcdba > March 2004 > Help:SQL SELECT QUERY
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Help:SQL SELECT QUERY
|
|
| Newbies 2004-03-22, 1:25 pm |
|
I have 3 tables in my database
The first Table is called Customers
The second Table is called Rooms
And the third table is a combination of the primary keys of Customer table
and the Rooms Table.
The Room tables consist of 50 rooms and only 30 of these rooms are currently
occupied. I need a query to find the available room numbers that are not
currently in use.
I have been able to write the query that return the room numbers that are
occupied
The query below is able to retrieve the occupied room
SELECT Room.Room, Room.Telefon
FROM ThirdTableINNER JOIN
Room ON ThirdTableINNER .RoomID = Room.RoomID
Thanks in advance
| |
| Cindy Winegarden 2004-03-22, 7:24 pm |
| In news: CZE7c.2267$px6.32062@news2.e.nsc.no,
Newbies <easyboy52@hotmail.com> wrote:
> I have 3 tables in my database
> The first Table is called Customers
> The second Table is called Rooms
> And the third table is a combination of the primary keys of Customer
> table and the Rooms Table.
> The Room tables consist of 50 rooms and only 30 of these rooms are
> currently occupied. I need a query to find the available room numbers
> that are not currently in use.
>
> I have been able to write the query that return the room numbers that
> are occupied
> SELECT Room.Room, Room.Telefon
> FROM ThirdTable INNER JOIN
> Room ON ThirdTableINNER .RoomID = Room.RoomID
Hi Newbies,
Try a left join where the value is null -
SELECT Room.Room, Room.Telefon
FROM ThirdTable
LEFT JOIN Room ON
ThirdTable.RoomID = Room.RoomID
WHERE
ThirdTable.RoomID Is Null
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org www.cindywinegarden.com
| |
| Newbies 2004-03-23, 1:24 pm |
| Thank you Cindy for the reply, when I run the query I could not get any
rows returned, I just replace the Left Join with Right Join, It's works
fine. Thanks for the input
"Cindy Winegarden" <cindy.winegarden@mvps.org> wrote in message
news:OHqF0aGEEHA.1268@TK2MSFTNGP09.phx.gbl...
> In news: CZE7c.2267$px6.32062@news2.e.nsc.no,
> Newbies <easyboy52@hotmail.com> wrote:
>
> Hi Newbies,
>
> Try a left join where the value is null -
>
>
> SELECT Room.Room, Room.Telefon
> FROM ThirdTable
> LEFT JOIN Room ON
> ThirdTable.RoomID = Room.RoomID
> WHERE
> ThirdTable.RoomID Is Null
>
> --
> Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
> cindy.winegarden@mvps.org www.cindywinegarden.com
>
>
>
| |
| Cindy Winegarden 2004-03-23, 6:24 pm |
| In news: aH_7c.2502$zf6.33833@news4.e.nsc.no,
Newbies <easyboy52@hotmail.com> wrote:
> Thank you Cindy for the reply, when I run the query I could not get
> any rows returned, I just replace the Left Join with Right Join, It's
> works fine.
You're right - my bad.
--
Cindy Winegarden MCSD, Microsoft Visual FoxPro MVP
cindy.winegarden@mvps.org www.cindywinegarden.com
|
|
|
|
|