Hello,
When I remove MYTABLE5.HAPPYCAPACITY from the SELECT clauses of the
following query, the number of rows returned drops from 28 to 24. If
I put it back in it goes back up to 28. Any idea how this is
possible?
Thanks,
Eric
SELECT
MYTABLE2.ACCOUNTID, MYTABLE2.HostOwnershipType AS COAPPTYPE,
MYTABLE5.HAPPYCAPACITY
FROM MYTABLE1, CUSTOMERS, SPECIALCUSTOMERS MYTABLE2,
SPECIALCUSTOMERS MYTABLE3, MYTABLE5
WHERE MYTABLE1.HAPPY = 'Yes'
AND MYTABLE1.BUDDYNAME = (CUSTOMERS.FIRSTNAME || ' ' ||
CUSTOMERS.LASTNAME)
AND (CUSTOMERS.MIDDLENAME IS NULL OR CUSTOMERS.MIDDLENAME = '')
AND CUSTOMERS.CUSTOMERID = MYTABLE2.CUSTOMERID
AND MYTABLE1.CUSTOMERID = MYTABLE3.CUSTOMERID
AND MYTABLE1.CUSTOMERID = MYTABLE5.CUSTOMERID
UNION
SELECT
MYTABLE2.ACCOUNTID, MYTABLE2.HostOwnershipType AS COAPPTYPE,
MYTABLE5.HAPPYCAPACITY
FROM MYTABLE1, CUSTOMERS, SPECIALCUSTOMERS MYTABLE2,
SPECIALCUSTOMERS MYTABLE3, MYTABLE5
WHERE MYTABLE1.HAPPY = 'Yes'
AND MYTABLE1.BUDDYNAME = (CUSTOMERS.FIRSTNAME || ' ' ||
CUSTOMERS.MIDDLENAME || ' ' || CUSTOMERS.LASTNAME)
AND CUSTOMERS.MIDDLENAME IS NOT NULL AND CUSTOMERS.MIDDLENAME <> ''
AND CUSTOMERS.CUSTOMERID = MYTABLE2.CUSTOMERID
AND MYTABLE1.CUSTOMERID = MYTABLE3.CUSTOMERID
AND MYTABLE1.CUSTOMERID = MYTABLE5.CUSTOMERID; 1 1359
UNION removes duplicates from the result, try UNION ALL if you want
all rows returned.
Regards,
Miro
Eric Goforth wrote: Hello,
When I remove MYTABLE5.HAPPYCAPACITY from the SELECT clauses of the following query, the number of rows returned drops from 28 to 24. If I put it back in it goes back up to 28. Any idea how this is possible?
Thanks, Eric
SELECT MYTABLE2.ACCOUNTID, MYTABLE2.HostOwnershipType AS COAPPTYPE, MYTABLE5.HAPPYCAPACITY FROM MYTABLE1, CUSTOMERS, SPECIALCUSTOMERS MYTABLE2, SPECIALCUSTOMERS MYTABLE3, MYTABLE5 WHERE MYTABLE1.HAPPY = 'Yes' AND MYTABLE1.BUDDYNAME = (CUSTOMERS.FIRSTNAME || ' ' || CUSTOMERS.LASTNAME) AND (CUSTOMERS.MIDDLENAME IS NULL OR CUSTOMERS.MIDDLENAME = '') AND CUSTOMERS.CUSTOMERID = MYTABLE2.CUSTOMERID AND MYTABLE1.CUSTOMERID = MYTABLE3.CUSTOMERID AND MYTABLE1.CUSTOMERID = MYTABLE5.CUSTOMERID UNION SELECT MYTABLE2.ACCOUNTID, MYTABLE2.HostOwnershipType AS COAPPTYPE, MYTABLE5.HAPPYCAPACITY FROM MYTABLE1, CUSTOMERS, SPECIALCUSTOMERS MYTABLE2, SPECIALCUSTOMERS MYTABLE3, MYTABLE5 WHERE MYTABLE1.HAPPY = 'Yes' AND MYTABLE1.BUDDYNAME = (CUSTOMERS.FIRSTNAME || ' ' || CUSTOMERS.MIDDLENAME || ' ' || CUSTOMERS.LASTNAME) AND CUSTOMERS.MIDDLENAME IS NOT NULL AND CUSTOMERS.MIDDLENAME <> '' AND CUSTOMERS.CUSTOMERID = MYTABLE2.CUSTOMERID AND MYTABLE1.CUSTOMERID = MYTABLE3.CUSTOMERID AND MYTABLE1.CUSTOMERID = MYTABLE5.CUSTOMERID; This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Egor Shipovalov |
last post by:
I'm implementing paging through search results using cursors. Is there a
better way to know total number of rows under a cursor than running a
separate COUNT(*) query? I think PostgreSQL is bound...
|
by: Alex Satrapa |
last post by:
I have a table from which I'm trying to extract certain information. For
historical reasons, we archive every action on a particular thing
('thing' is identified, funnily enough, by 'id'). So the...
|
by: Robert |
last post by:
I am trying to create a db for service providers by county. I'm relatively
new to db programming, but I have done quite a bit of programming ranging
from the old basic days up to doing some...
|
by: Smartin |
last post by:
Using Access 97
I am trying to create a form that allows for user entry of search terms
and displays a table of results. I thought I could accomplish this using
a subform but it isn't quite...
|
by: Klint Gore |
last post by:
query is
select t2.field4, t1.*
from t1
left outer join t2 on t2.field1 = t1.field1 and t2.field2 = t1.field2
There are 55k rows in t1 (103 fields) and 10k in t2 (4 fields, 4 is text)....
|
by: cover |
last post by:
I have a table with 50 fields that receive input depending on whether
that input came in from a 'shaker' form or a 'conveyor' form. Input
from the 'conveyor' form might populate 25 fields while...
|
by: Merennulli |
last post by:
To start with, I'll give a simplified overview of my data.
BaseRecord (4mil rows, 25k in each Region)
ID | Name | Region | etc
OtherData (7.5mil rows, 1 or 2 per ID)
ID | Type(1/2) | Data
...
|
by: DeanL |
last post by:
Hi all,
I'm trying to set up a query that runs from a command button on a form
(simple enough so far), what I want the query to do is take values
from the fields on the form (seven fields in...
|
by: prn |
last post by:
Hi Folks,
Sorry if I have the forum wrong, It's more a SQL question than a SQL Server question, but it is intended to run on MS SQL Server at least. :)
I'm trying to construct a query and am...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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...
|
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...
| |