473,386 Members | 1,741 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,386 software developers and data experts.

Union/Select or Join Query

I have one table that gets updated daily by an outside source I created
anohter table that never changes however it has some of the same data as the
first table.
Table1 - inmtinfo
IN_INMNUM
IN_NAME
IN_RACE
IN_BLDING
IN_SECTION
IN_CELLDRM
IN_BEDNUM
SEP
Table 2 - tblCellData
CellID
Section
Cell#
Bed
Table 1 lists all inmates and inforamtion for all units in the prison.
Table 2 lists only the Cell data for our RHU.
What I need to do is to join the two tables and return all the data from
Table 2 even if there is no matching data from Table 1.
(It should return IN_INMNUM, IN_NAME, IN_RACE & SEP from Table 1 if
IN_BLDING = H and all the data from Table 2)
This is the code I have now and it is only pulling the data from Table 2
that has matching data in Table 1. I need all of Table 2 and only the data
that matches from Table 1.
Example.
IN_INMNUM - IN_NAME - IN_RACE - IN_BLDING - Section - Cell# - Bed - SEP
EX1234 Smith W H A 1001 01 na
A 1002 01
EX2345 Davis B H A 1002 01 na

MY SQL Code

SELECT inmtinfo.IN_INMNUM, inmtinfo.IN_NAME, inmtinfo.IN_RACE,
inmtinfo.IN_BLDING, tblCellData.Section, tblCellData.[Cell#],
tblCellData.BED, inmtinfo.SEP
FROM inmtinfo RIGHT JOIN tblCellData ON (inmtinfo.IN_SECTION =
tblCellData.Section) AND (inmtinfo.IN_CELLDRM = tblCellData.[Cell#]) AND
(inmtinfo.IN_BEDNUM = tblCellData.BED)
WHERE (((inmtinfo.IN_BLDING)="H"));
Sep 27 '06 #1
2 2161
PEB
1,418 Expert 1GB
And what do you want about? Pb with your queries or what???
Sep 30 '06 #2
I want to use the query in a form where they can enter information into the righ half of the query.
Oct 1 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: dmb000006 | last post by:
My question is about a UNION query to deal with an (annoying) JOIN over two tables. I am joining over a double column primary key (where the order of the columns can be changed). This is sooo...
3
by: Matias Silva | last post by:
Hi Everyone, I wrote a for loop to build several select statements that are combined with a UNION. When I execute one of the queries separately, it works, but when I execute the query with a UNION...
1
by: jtwright | last post by:
I've got a view that creates a parent child relationship, this view is used in Analysis Services to create a dimension in a datastore. This query tends to deadlock after about 10 days of running...
2
by: mattytee123 | last post by:
I have about 20 tables, of which I would like to do a union query and count of how many of each different code there is? The simplified verson of the table is structured like this. Code ...
2
by: Thomas | last post by:
Hi All. I think that if I explain the database layout first it may be easier to ask my question. Table Name Field Name Test TestCode Description SpecimenRequirements FeeSchedule TestCode...
7
by: KoliPoki | last post by:
Hello every body. I have a small issue. Problem: I have a table with 4 descriptor columns (type). I need to formulate a query to retrieve a count for each type so I can group by...etc. The...
4
by: janko.klemensek | last post by:
Can I Group by the Union in one query or must I write two queries for this (one for union and second for group by)?
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...
2
by: MLH | last post by:
I have a saved UNION query named qryAuthsOwnersAddnlOwnersLienholders4OneCar. Here it is... SELECT & " " & & " " & & " " & & ", " & & " " & & " " & "(" & & " county) " &...
5
zachster17
by: zachster17 | last post by:
Hi everyone, First of all, sorry for the massive amount of SQL I am about to type. I have a database that has a "lives" table of insured employees and then another table (that links to the lives...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.