473,469 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I have an odd SELECT that I am having problems with...


Folks,

Can I perform a single select query on two tables, where the results
will include an optional value that might be in the second table?

let me explain:
I have two tables - address and department.

The address table has a unique column to help identify the address (a
hash key).

The department table *could* have records, and if it does, it will have
a hash corresponding to address.hash.

Can I perform a SELECT to retrieve my address records from address table
and include any optional records that some addresses might have in the
department table?

Do I have to perform two seperate selects for this, or is there a method
for me to do this all in one query? My guess is two seperate selects...

Help is appreciated - replies via the newsgroup to help others... thanks

randell d.

Jul 23 '05 #1
2 979
Randell D. wrote:
Can I perform a SELECT to retrieve my address records from address table
and include any optional records that some addresses might have in the
department table?


A surprisingly high portion of tricky SQL query questions on this
newsgroup can be solved with an outer join! :-)

SELECT *
FROM address AS a LEFT OUTER JOIN department AS d
ON a.hash = d.hash;

Regards,
Bill K.
Jul 23 '05 #2
Bill Karwin wrote:
Randell D. wrote:
Can I perform a SELECT to retrieve my address records from address
table and include any optional records that some addresses might have
in the department table?

A surprisingly high portion of tricky SQL query questions on this
newsgroup can be solved with an outer join! :-)

SELECT *
FROM address AS a LEFT OUTER JOIN department AS d
ON a.hash = d.hash;

Regards,
Bill K.


I'm only just learning to understand JOINs... I appreciate the solution...

Thanks
Randell D.
Jul 23 '05 #3

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

Similar topics

3
by: Christopher Brandsdal | last post by:
Hi! I am having some problems width a little script i downloaded... I'm not able to figure out what he SELECT line does! What does the @@identity mean? Is this maby a javascript? :)
8
by: Adam Nemitoff | last post by:
Is is possible to construct a SELECT statement that contains a WHERE clause that uses the value from a column in the "next" row? ie. given a table with a single field named "myField" with the...
12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
1
by: ST | last post by:
Hi, I'm trying to debug someone else's code, and I'm going thru this Select Case statement. I'm having problems with the "OTHER" case...in that when the first line of the case is false, it jumps...
19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
12
by: Doug Bell | last post by:
Hi, I am having problems trying to create a (temporary) DataTable from a selection from a DataGrid (dgOrders). dtOrdDetails is declared as a Public DataTable Sub is: Dim stFilter as String...
5
by: Henning M | last post by:
Hi all, I having some problems with Access and selecting records between dates.. When I try this in access, it works fine!! "Select * from Bilag Where Mdates Between #1/1/2006# And...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
17
by: Sam Kong | last post by:
Hello, There are 1 or more select elements with the same name in a form. Let's say that the name of the select is 'select1' and the name of the form is 'form1'. If there's only one select I...
1
by: ProgrammingStudent | last post by:
I have 2 tables: Customer Table -CustomerID -CustomerName -CustomerState Invoice Table -InvoiceID -CustomerID
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
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.