473,474 Members | 1,884 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Multiple Query

I am trying to get the technician contractor(TECHCONT) of last field
technician (FS_TechID or LstVldTech). It could be in Tbl_ValidDispute
or Tbl_PPVResearch.

In table Tbl_PPVResearch first i have to match the first 5 digits of
Account number with Tech_ID.CORP and once it match i have to find last
field technician from all three
fields(FS_TechID1,FS_TechID2,FS_TechID3). First five digits of account
number in both tables are the CORP in table Tech_ID. The structure of
Tbl_PPVResearch is if FS_TechID3 is not empty it means that FS_TechID3
is a last field technician or if FS_TechID3 is empty then FS_TechID2 is
last field technician or if FS_TechID3 and FS_TechID2 is empty than
last field technician is FS_TechID1. Once i got the FS_TechID then
match it with Tech_ID.Tech and if match then get the technician
contractor from Tech_ID.TECHCONT

In another table Tbl_ValidDispute first five digits of all three
accounts are CORP. I have to match first the accounts with CORP and if
one is match then i have to match the LstVldTech with Tech_ID.Tech and
get the technician contractor (TECHCONT)
Thing which is in my mind is to write three separate queries first to
get the corp from two tables (Mid([AccountNum],2,4) AS Corp and then
write main query. Any help in creating query very appreciate.

Thanks in advance.

Tbl_PPVResearch
---------------
TicketNum Autonumber PK
AccountNum Type Text 00000-000000-00
FS_TechID1 Type Text 00000
FS_TechID2 Type Text 00000
FS_TechID3 Type Text 00000

Tbl_ValidDispute
-----------------
TicketNum
LstVldTech Type Text 00000
OtherAcct1 Type Text 00000-000000-00
OtherAcct2 Type Text 00000-000000-00
OtherAcct3 Type Text 00000-000000-00

Tech_ID
-------
ID PK
CORP Type Text 00000
Tech Type Text 00000
TECHCONT Type Text

Sep 3 '06 #1
4 1406

Eric wrote:
I am trying to get the technician contractor(TECHCONT) of last field
technician (FS_TechID or LstVldTech). It could be in Tbl_ValidDispute
or Tbl_PPVResearch.

Tbl_PPVResearch
---------------
TicketNum Autonumber PK
AccountNum Type Text 00000-000000-00
FS_TechID1 Type Text 00000
FS_TechID2 Type Text 00000
FS_TechID3 Type Text 00000

Tbl_ValidDispute
-----------------
TicketNum
LstVldTech Type Text 00000
OtherAcct1 Type Text 00000-000000-00
OtherAcct2 Type Text 00000-000000-00
OtherAcct3 Type Text 00000-000000-00

Tech_ID
-------
ID PK
CORP Type Text 00000
Tech Type Text 00000
TECHCONT Type Text
Getting the first/last TechID is going to be a nightmare if you don't
NORMALIZE. there's a reason for all those papers the Codd wrote. The
OterAcct(1,2,3) and FS_TechID(1,2,3) are key indicators that you need
to normalize in a bad way. If I were you'd, I'd stop for a while and
read up on normalization theory, because in this case, it really
matters. I'd start with Hernandez's Databases for Mere Mortals.

Why? Try querying this kind of structure. Hope you like UNION
queries. LOTS of them. Because that's the only way you can get this
kind of structure to be even close to functional. And even then it's
going to be a pain.

Glad it's your DB and not mine.

Sep 3 '06 #2
Database is old which is running in my company and it contains more
than 100,000 records. I need the report and i dont know do i use the
query or do i write a VB method to fetch the record.

When user enter the CORP and Tech, it goes to Tbl_PPVResearch and match
it with first 4 digit of AccountNum and Tech with FS_TechID1,
FS_TechID2, FS_TechID3. I need the last technician from all three
FS_TechID. If it match it fetch the record.
Then it goes to Tbl_ValidDispute search the CORP in all three
OtherAcct(OtherAcct1,OtherAcct2,OtherAcct3) if it match then it search
the Tech in LstVldTech once both match it fetch the record.

Thanks,
pi********@hotmail.com wrote:
Eric wrote:
I am trying to get the technician contractor(TECHCONT) of last field
technician (FS_TechID or LstVldTech). It could be in Tbl_ValidDispute
or Tbl_PPVResearch.

Tbl_PPVResearch
---------------
TicketNum Autonumber PK
AccountNum Type Text 00000-000000-00
FS_TechID1 Type Text 00000
FS_TechID2 Type Text 00000
FS_TechID3 Type Text 00000

Tbl_ValidDispute
-----------------
TicketNum
LstVldTech Type Text 00000
OtherAcct1 Type Text 00000-000000-00
OtherAcct2 Type Text 00000-000000-00
OtherAcct3 Type Text 00000-000000-00

Tech_ID
-------
ID PK
CORP Type Text 00000
Tech Type Text 00000
TECHCONT Type Text

Getting the first/last TechID is going to be a nightmare if you don't
NORMALIZE. there's a reason for all those papers the Codd wrote. The
OterAcct(1,2,3) and FS_TechID(1,2,3) are key indicators that you need
to normalize in a bad way. If I were you'd, I'd stop for a while and
read up on normalization theory, because in this case, it really
matters. I'd start with Hernandez's Databases for Mere Mortals.

Why? Try querying this kind of structure. Hope you like UNION
queries. LOTS of them. Because that's the only way you can get this
kind of structure to be even close to functional. And even then it's
going to be a pain.

Glad it's your DB and not mine.
Sep 3 '06 #3
Use a query. The reason I said to normalize this is that querying a
non-normalized database is a total PITA. You get the OR problems like
the ones you posted. And forget summarizing data. You _can_ use union
queries to get normalized views of the data, but union queries are not
updateable.

i would still create queries to sort of normalize the data, and then
base my final queries on the "normalized" views. This design is a
disaster.

Sep 5 '06 #4

Eric wrote:
Database is old which is running in my company and it contains more
than 100,000 records. I need the report and i dont know do i use the
query or do i write a VB method to fetch the record.
If you don't know how to write queries, you're in pretty deep trouble.
I would go out and get a good book on Access if I were you. John
Viescas's books are good, Roger Jennings is good. For Dummies books
are usually worthless.

I don't mean to be ugly at all, but making a badly denormalized
database functional is not that easy. If you absolutely have to leave
the database structure as is, I would union the repeating junk together
into a virtual table and use those to query.

There are just so many normalization problems with this database it's
not even funny.

Basic union query...

SELECT tbl_PPVResearch.AccountNum, FS_TechID1 As FS_TechID
FROM tbl_PPVResearch
WHERE tbl_PPVResearch.FS_TechID1 IS NOT NULL
UNION ALL
SELECT tbl_PPVResearch.AccountNum, FS_TechID2 As FS_TechID
FROM tbl_PPVResearch
WHERE tbl_PPVResearch.FS_TechID1 IS NOT NULL
SELECT tbl_PPVResearch.AccountNum, FS_TechID3 As FS_TechID
FROM tbl_PPVResearch
WHERE tbl_PPVResearch.FS_TechID1 IS NOT NULL;

Do that with each table that has fieldName(1,2,3...)
Then you should be able to get reasonable queries out of this thing.

Once you've done that for all the screwy tables, base your queries on
these union queries. As long as you don't try to run updates and
deletes through these queries, you can get the information you need out
of it, I think.

God be with ya. You may need it.

Sep 6 '06 #5

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

Similar topics

7
by: Rick Caborn | last post by:
Does anyone know of a way to execute sql code from a dynamically built text field? Before beginning, let me state that I know this db architecture is built solely for frustration and I hope to...
4
by: DG | last post by:
Hi, Can anyone advise how to execute multiple statements in a single query batch. For example- update customers set customer_name = 'Smith' where customer_name = 'Smyth'; select * from...
5
by: Sami | last post by:
I can create queries and reports based on info from one table. How do I create one using information from multiple tables. What do I need to make sure the information from one table will be...
4
by: carl.barrett | last post by:
Hi, I have a list box that displays 2 columns. Behind it sits a query with five columns. These are Column1 (DOB), column2 (a concatenated string of Surname Forname, Title), Column3 (Surname),...
3
by: mkjets | last post by:
I have worked for hours on trying to find a solution and have not figured it out. I am working in Access 2003. I need to create a query that takes values from 1 table and displays them in...
2
by: yxktmp | last post by:
Hi; I have a main starting query for most of my reporting. I branch out from this query to other queries. This main query contains multiple form control filters (query criterias) . I want to use...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables,...
92
by: bonneylake | last post by:
Hey Everyone, Well i was hoping someone could explain the best way i could go about this. i have a few ideas on how i could go about this but i am just not sure if it would work. Right now i...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
482
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if this is more of a coldfusion problem or a javscript problem. So if i asked my question in the wrong section let me know an all move it to the correct place. ...
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
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,...
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?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.