473,396 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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.tenant is the same as tenant.tenant_ID

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 1298
Sorry its my first post! Not sure how to do it!
Dec 11 '14 #2
Rabbit
12,516 Expert Mod 8TB
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
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...
0
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...
3
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...
4
by: Elroyskimms | last post by:
Using SQL 2000... tblCustomer: CustomerID int CompanyName varchar(20) HasRetailStores bit HasWholesaleStores bit HasOtherStores bit tblInvoiceMessages:
1
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...
5
by: Eitan M | last post by:
Hello, How can I do outer join in ms-access database ? Thanks :)
2
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...
4
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....
3
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...
2
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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
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,...

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.