473,503 Members | 3,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Only the first result gets a value

1 New Member
Hi all,

Fun problem for everyone over the weekend - :)

OK so I have the following SQL query in Access.....

SELECT x.SURVEY_DATE AS [Survey Date], z.ORIG_CONST_DATE, z.ORIG_EXP_NO
FROM [select * from x00]. AS x, [select * from zG]. AS z;

Note: x00 and zG are other queries in the same MDB File
Note also: zG only returns one record

The problem is that only the first record returned gets a value for z.ORIG_CONST_DATE but all records get a value for z.ORIG_EXP_NO. Why is this? If z is a table with one record all records get a date....Why does it matter if zG is a table or query?? Also if this is the normal behavior how do i put the z.ORIG_CONST_DATE into all records??

Thankyou everyone in advance for your wonderful work!!!

For completeness:

x00:
//returns about 20 records
SELECT SURVEY_DATE FROM MON_DIS_PADIAS_JPCC WHERE STATE_CODE=STATE And SHRP_ID=SHRP;

zG:
//returns 1 record
SELECT GPS_SPS+EXPERIMENT_NO AS ORIG_EXP_NO, ORIG_CONST_DATE FROM EXPERIMENT_SECTION
WHERE CONSTRUCTION_NO=1 AND STATE_CODE = [STATE] AND SHRP_ID = [SHRP];
Oct 13 '06 #1
1 1258
jimatqsi
1,271 Recognized Expert Top Contributor
I think you're going to need to add a JOIN statement... add a keyfield to each query and join them together with it. Here's an example from something I'm doing...

SELECT Family.*, Family.FamilyName, Items.Item AS Expr1
FROM Family LEFT JOIN Items ON Family.FamilyCode = Items.FamilyCode;
and

SELECT Family.*, Family.FamilyName, Items.Item AS Expr1
FROM Family RIGHT JOIN Items ON Family.FamilyCode = Items.FamilyCode;

The first one gives me all 1,087 items in my Item table, and the Family name of each item.

The second one gives me 1,093 records.. I'm getting all 15 of the families listed and any of the Items coded for those families. Six of them have a blank where the Item number should be. That's because there are 6 familes defined that have no item numbers coded to be in that family (the JOIN failed in those cases)

Let me know if this helps or not.
Jim
Oct 14 '06 #2

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

Similar topics

11
2141
by: Amilcar | last post by:
Hi: I have a problem: I've a page that sends an encrypted password, using MD5, to a PHP file, which is able to compare such MD5 encrypted password with an encryption stored on a data base. But...
8
5451
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
24
19859
by: clare at snyder.on.ca | last post by:
I have a SQL query I need to design to select name and email addresses for policies that are due and not renewed in a given time period. The problem is, the database keeps the information for every...
13
2099
by: jfarthing | last post by:
Hi everyone! I am using the script below to search a db. If the is more than one match in the db, all goes well. But if there is only one match in the db, nothing gets displayed. Any...
0
7192
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
7064
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
7315
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...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
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
4665
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
3158
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
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.