473,609 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Union with another subquery…can't join the two together

4 New Member
I have a table Rent_Payment with subclasses checks and like_value (PK is payment_ID). Each of the subclasses have a description (ex: like_value has 'Fixed a car'). Tenant pays the Rent Payment (linked by FK tenant_ID). I want to display:
Tenant, and description from the subclass of how they paid. I unioned all the subclasses but I don't understand how to use the union and make sure that the rent_payment.te nant is the same as tenant.tenant_I D

Expand|Select|Wrap|Line Numbers
  1. select tenant.fn, tenant.ln, rent_payment.AMOUNT,checks.check_desc, direct_deposit.DEPOSIT_DESC, like_value.description
  2.   from tenant, rent_payment, checks, direct_deposit, like_value
  3.     where rent_payment.tenant_ID = tenant.tenant_ID AND
  4.  
  5. select rent_payment.payment_ID
  6.   from rent_payment, checks
  7.   where rent_payment.payment_ID = checks.payment_ID
  8.    UNION
  9. select rent_payment.payment_ID
  10.   from rent_payment, direct_deposit
  11.       where rent_payment.payment_ID = direct_deposit.payment_ID
  12.     UNION
  13. select rent_payment.payment_ID
  14.   from rent_payment, like_value
  15.   where rent_payment.payment_ID = like_value.payment_ID;

The union all works on its own and the top part (up until the AND) all works on its own too…its just how to put them together I am having an issue with.
Dec 11 '14 #1
2 1301
catherineadams
4 New Member
Sorry its my first post! Not sure how to do it!
Dec 11 '14 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Instructions on how to use the forum are in the FAQ.

If you want to pull data from those 3 tables: checks, direct_deposit, like_value. Then you need to outer join to those tables.

If you don't know what an outer join is, that is explained in the SQL tutorial located here: http://www.w3schools.com/sql/sql_join_left.asp
Dec 11 '14 #3

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

Similar topics

0
2432
by: Tomas | last post by:
I would like to know if and how it is possible to join the *result* of a union with another table (without first doing individual joins to each part of the result that then will be combined into a union) ?? For example, I would like to do such a join, if possible, to avoid doing something like this: select tableA.col1 as c1 , tableC.col2, tableC.col3, tableC.col4, tableC.col5, ..... from tableA inner join tableC on tableA.col1 =...
0
503
by: Paradigm | last post by:
I am trying to make a union query to join 4 tables. I have reduced the tables to just 5 fields and made sure that the field types and names are the same. I keep getting an error message ODBC call failed. I have tried various combinations of the tables and find that I can use any 2 of them but as soon as a third is included in the statement the query fails. Is there a limit on the number of tables in a union query. The union query looks...
3
11968
by: Blake Caraway | last post by:
All, I've seen several posts regarding using UNION or UNION ALL to mash together two or more resultsets into a single result set, but can't seem to find enough info here to help me answer my particular question. I have a stored procedure that gets the column names in a particular format (i.e. "chassis_id"|"chassis_description"|"modify_date") as well as actual data for a given table (in a quote-separated, pipe-delimited
4
6934
by: Elroyskimms | last post by:
Using SQL 2000... tblCustomer: CustomerID int CompanyName varchar(20) HasRetailStores bit HasWholesaleStores bit HasOtherStores bit tblInvoiceMessages:
1
7768
by: CrystalDBA | last post by:
I usually design applications in SQL Server and Crystal Reports. I now need to create a crystal report on an MS Access database. I have two tables: Services: Date datetime Entry text Amount number (should be 4 records)
5
3280
by: Eitan M | last post by:
Hello, How can I do outer join in ms-access database ? Thanks :)
2
2174
by: mlarson | last post by:
I have one table that gets updated daily by an outside source I created anohter table that never changes however it has some of the same data as the first table. Table1 - inmtinfo IN_INMNUM IN_NAME IN_RACE IN_BLDING IN_SECTION IN_CELLDRM
4
4279
by: Andrew S | last post by:
Hello Mr. Expert: - I have 3 tables in mysql in MyISAM table format, I am using mysql4.0 on freebsd5.3 - producttbl, productdetailentbl, pricetblN - they all have "productid" as the Primary KEY. there are less than 300,000 records in each table - when I ran the statement select productname from productdetailentbl left join producttbl on productdetailentbl.productid=producttbl.productid left join pricetblN on...
3
1615
daniel aristidou
by: daniel aristidou | last post by:
hi i made a union query to join about 9 tables together. however when i press run an error message apears saying that it could not find object: ". Any way so i started again and ran it after every new table joined. and the error only occurs after the 3rd table entry. but after the third table entry is removed the error message remains and it will not run. Does any body know why this happens. I have not even typed in any ". Also can anyone...
2
2813
by: rogerford | last post by:
I have two tables tbl_Dropdownlist and tbl_ListbValues tbl_Dropdownlist has fol. Columns. DDLid -PK DDLName tbl_ListValues has fol. columns. ListValueId DDlid – FK
0
8067
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,...
0
8567
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8527
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 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...
0
8398
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6993
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, 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...
1
6053
isladogs
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...
0
5509
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();...
0
4076
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1380
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.