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_Element_ID" has a single record against it but I want the record to be the one where (NOT (Form_Element_Server_Process_Code IS NULL)) AND (NOT (Form_Element_Site_Id IS NULL)) and disregard the other bogus records. However say this if (NOT (Form_Element_Server_Process_Code IS NULL)) AND (NOT (Form_Element_Site_Id IS NULL)) do not exist then display the records (NOT (Form_Element_Server_Process_Code IS NULL)) OR
(NOT (Form_Element_Site_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 1128 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...
|
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...
|
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...
|
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...
|
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: 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...
|
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...
|
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...
|
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...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| | |