Hi there,
I am trying to do a UNION with slightly different queries, it appears to work but it now bring in another problem. The second part of the UNION need to have a an extra field value ("NULL") added thus to match the number of fields between the two select queries. The problem comes that I some have duplicate records and want to condense them down so that "Table_Form_Ele ment_ID" has a single record against it but I want the record to be the one where (NOT (Form_Element_S erver_Process_C ode IS NULL)) AND (NOT (Form_Element_S ite_Id IS NULL)) and disregard the other bogus records. However say this if (NOT (Form_Element_S erver_Process_C ode IS NULL)) AND (NOT (Form_Element_S ite_Id IS NULL)) do not exist then display the records (NOT (Form_Element_S erver_Process_C ode IS NULL)) OR
(NOT (Form_Element_S ite_Id IS NULL)).
The current query is producing the following:- -
-
SELECT Form_Storage_Process_Order, Form_Element_Server_Process_Code, Table_Form_Element_ID, Table_Form_Table_Name, Table_Form_Element_Key, Table_Form_Element_Name, Table_Form_Element_Type, Table_Form_Element_Length, Form_Element_Site_Id, Form_Id
-
FROM (SELECT cTbl.Form_Storage_Process_Order AS Form_Storage_Process_Order, cTbl.Form_Element_Server_Process_Code AS Form_Element_Server_Process_Code, dTbl.Table_Form_Element_ID AS Table_Form_Element_ID, dTbl.Table_Form_Table_Name AS Table_Form_Table_Name, dTbl.Table_Form_Element_Key AS Table_Form_Element_Key, dTbl.Table_Form_Element_Name AS Table_Form_Element_Name, dTbl.Table_Form_Element_Type AS Table_Form_Element_Type, dTbl.Table_Form_Element_Length AS Table_Form_Element_Length, bTbl.Form_Element_Site_Id AS Form_Element_Site_Id, eTbl.Form_Id AS Form_Id
-
FROM WWWFORM_SITE_ELEMENT_LAYOUT aTbl INNER JOIN
-
WWWFORM_SITE_ELEMENT bTbl ON aTbl.Form_Element_Site_Id = bTbl.Form_Element_Site_Id INNER JOIN
-
WWWDATABASE_STORAGE_PROSESS_GROUP cTbl ON aTbl.Form_Element_Layout_Id = cTbl.Form_Element_Layout_Id INNER JOIN
-
WWWDATABASE_STORAGE_PROSESS_STRUCTURE dTbl ON cTbl.Table_Form_Element_ID = dTbl.Table_Form_Element_ID INNER JOIN
-
WWWFORM eTbl ON eTbl.Form_Storage_Process_Type_Id = cTbl.Form_Storage_Process_Type_Id
-
UNION
-
SELECT cTbl.Form_Storage_Process_Order AS Form_Storage_Process_Order,
-
cTbl.Form_Element_Server_Process_Code AS Form_Element_Server_Process_Code,
-
dTbl.Table_Form_Element_ID AS Table_Form_Element_ID, dTbl.Table_Form_Table_Name AS Table_Form_Table_Name,
-
dTbl.Table_Form_Element_Key AS Table_Form_Element_Key, dTbl.Table_Form_Element_Name AS Table_Form_Element_Name,
-
dTbl.Table_Form_Element_Type AS Table_Form_Element_Type, dTbl.Table_Form_Element_Length AS Table_Form_Element_Length, NULL,
-
eTbl.Form_Id AS Form_Id
-
FROM WWWDATABASE_STORAGE_PROSESS_GROUP cTbl INNER JOIN
-
WWWDATABASE_STORAGE_PROSESS_STRUCTURE dTbl ON cTbl.Table_Form_Element_ID = dTbl.Table_Form_Element_ID INNER JOIN
-
WWWFORM eTbl ON eTbl.Form_Storage_Process_Type_Id = cTbl.Form_Storage_Process_Type_Id) DERIVEDTBL
-
WHERE (NOT (Form_Element_Server_Process_Code IS NULL)) OR (NOT (Form_Element_Site_Id IS NULL)) AND (Form_Id = '1')
-
If anyone knows how I can get around this problem I would be very grateful. Its giving me a headache. I am not familiar with If Else Clauses in SQL but I feel that it must be possible.
Thanks
0 1144 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Gerry Abbott |
last post by:
Hi All,
I have one table with two tables linked to two index fields,
tblMain, MainId, CashId, CreditId
tblCash Cashid, CashValue
tblCredit, CreditId, CreditValue
Each record is either a credit or a cash record, and so either the CashId or
the CreditId will be completed. Is there a way I can query this info
(without changing the underlying data) to give me a table containing two
|
by: RLN |
last post by:
Re: Access 2000
I have three history tables.
Each table contains 3 years worth of data.
All three tables have a date field in them (and autonum field).
Each table has the potential to contain over 100K rows each.
A common request the user receives is a request to pull all data written
in a given month. I need to write some sort of union query across all
three tables that would pull data for, say, only the month of December
of all nine...
|
by: Nicolae Fieraru |
last post by:
Hi All,
I want to find if there is a different way than the way I am working now.
Lets say I have a table, tblCustomers containing address details.
I want a report with all the customers from a specific state. In order to
generate that, I create a form, I put a combobox with the states and a
Command Button which opens a report.
The report is based on a query, qryCustomersByState which has a parameter
(State) taken from the Form.
|
by: Jason |
last post by:
I have a primary form which is used to enter/edit data in a table
named Test_Results. On this primary form there is a subform which
displays site addresses. This subform is linked to the primary form
by field named TestID. The subform is used just for displaying site
address data, data which is stored in another table named
Total_Site_Address. In the Total_Site_Address table there are
numerous fields that form the site addresses...
|
by: Lenin Torres |
last post by:
Hi everybody
I have an Union Query that works fine. I used this query as the
RecordSource for a Form. That Form is used as a subform in another form.
Everything works fine, except for the "Filter by form" feature. When
the user tries to use Filter by form a messagebox is displayed: "There
are too many controls in this form to perform a filter by form", after
that,when the user exit the Filter by Form mode, Access crash,
displaying a...
| |
by: laurenq uantrell |
last post by:
Wondering if there is a physical or realistic limitation to the number
of UNION statements I can create in a query? I have a client with
approx 250 tables - the data needs to be kept in seperate tables, but I
need to be filtering them to create single results sets. Each table
holds between 35,000 - 150,000 rows. Should I shoot myself now?
lq
|
by: AJ |
last post by:
Hi all,
I have this monster query (at least i think it is).
SELECT
c.ID, c.Company_Name, p., 1 As QueryNbr
FROM
(Company AS c LEFT JOIN Sale AS s ON c.ID = s.Company_ID)
LEFT JOIN
Package AS p ON s.Package_ID = p.ID
|
by: bgreenspan |
last post by:
Hi Everyone, I'm back for some more expert help. Here's what I am
doing and what I tried.
My database has entries with Contract Names and Expiry Dates, among
other fields. I have a form designed to show the expiring contracts.
To do this I use a straight forward query in my form's ON LOAD code
strwhere = " BETWEEN #" & Now() & "# AND #" &
DateAdd("m", 6, Now()) & "#"
Set MyQueryDef = MyDatabase.CreateQueryDef("qryMattersQuery",...
|
by: billelev |
last post by:
Hi There,
I am performing a UNION query on a Table containing % formatted values with a Query, also containing % formatted values.
The resulting union query displays the table % values as decimal but the query % values as percents.
e.g.
Table, value1 = 3.5%
Query, value1 = 4.5%
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |