AnnieBrownTX
New Member
- Joined
- Feb 8, 2012
- Messages
- 2
Hi,
I am new to using Microsoft Query, and am having lots of trouble joining two tables and getting all the results in one table.
I have two very large tables:
MASTER
has 175,000+ rows of data and about 30 columns I need
FCLMST02
has about 23,000 rows and about 4 columns that I need
I have created my query to just get the columns I need, from both tables, but when I try to JOIN them, using the instructions below, option 2 is greyed out:
Both tables contain a common field: LOAN
I want to keep all the data in the MASTER table and add all the additional columns that is in the FCLMST02 table.
Any LOAN that is also listed in the FCLMST02 table should populate their columns, and all the other rows in the MASTER table that are not in the FCLMST02 table can say Null (or whatever).
I've tried writing my own SQL statement, actually I just amended the statement created by my query:
SELECT MASTER_0.M_LOAN, MASTER_0.M_SC, MASTER_0.M_INV_NO, MASTER_0.M_LIEN, MASTER_0.M_LN_TYP, MASTER_0.M_ORIG_TRM_MTHS, MASTER_0.M_PAY_FREQ, MASTER_0.M_LATE_DAY, MASTER_0.M_LC_AMT, MASTER_0.M_LATE_CHG_BAL, MASTER_0.M_INT_RATE, MASTER_0.M_ORIG_INT_RTE, MASTER_0.M_SUS_BAL, MASTER_0.M_UNAP_FND_BAL, MASTER_0.M_MERS_MIN, MASTER_0.M_MOD_FST_PMT_DUE_MM, MASTER_0.M_MOD_FST_PMT_DUE_DD, MASTER_0.M_MOD_FST_PMT_DUE_YY, MASTER_0.M_FHA_VA_PMI, MASTER_0.M_PMI_RATE, MASTER_0.M_PRIN_BAL, MASTER_0.M_P_I, MASTER_0.M_MTHLY_ESC, MASTER_0.M_ESC_ADV_BAL, MASTER_0.M_DUE_DT, MASTER_0.M_INT_CD, MASTER_0.M_OCC_CD, MASTER_0.M_ESC_BAL, MASTER_0.M_FCL_SALE_MM, MASTER_0.M_FCL_SALE_DD, MASTER_0.M_FCL_SALE_YY, MASTER_0.M_ORIG_LN_DT, MASTER_0.M_MAT_DT, MASTER_0.M_FST_DUE_DT, MASTER_0.M_LAST_INIT_DT, MASTER_0.M_BALLOON_DT, MASTER_0.M_LAST_PAY_REC_MM, MASTER_0.M_LAST_PAY_REC_DD, MASTER_0.M_LAST_PAY_REC_YY, MASTER_0.M_LAST_ANALYSIS_MM, MASTER_0.M_LAST_ANALYSIS_DD, MASTER_0.M_LAST_ANALYSIS_YY, MASTER_0.M_MTGR_NAME, MASTER_0.M_FICO_SCORE, MASTER_0.M_MTGR_SS_NO, MASTER_0.M_MAIL_ADDR_1, MASTER_0.M_MAIL_ADDR_2, MASTER_0.M_MAIL_CITY, MASTER_0.M_MAIL_ST, MASTER_0.M_MAIL_ZIP_CD1, MASTER_0.M_MAIL_ZIP_CD2, MASTER_0.M_PROP_NO, MASTER_0.M_PROP_DIR, MASTER_0.M_PROP_STREET_NAME, MASTER_0.M_PROP_CITY, MASTER_0.M_PROP_ST, MASTER_0.M_PROP_ZIP_CD1, MASTER_0.M_PROP_ZIP_CD2, MASTER_0.M_RM_PROP_TYP, MASTER_0.M_APPR_VAL, MASTER_0.M_INDX_CD, MASTER_0.M_INDX_TYP, MASTER_0.M_NOTC_REQ, MASTER_0.M_INT_FCTR, MASTER_0.M_INT_CHG_FRQ, MASTER_0.M_RM_BEG_INDEX, MASTER_0.M_INDX_ADJ, MASTER_0.M_MAX_INT_DEC, MASTER_0.M_MAX_INT_INC, MASTER_0.M_MIN_ANUL_INT_DEC, MASTER_0.M_MIN_ANUL_INT_INC, MASTER_0.M_PREV_INT_RTE, MASTER_0.M_L_PMT_CHG_DT, MASTER_0.M_NXT_INT_CHG_DT, FCLMST02_0.CURRENT_APPRAISAL_AMT, FCLMST02_0.CURRENT_APPRAISAL_DATE, MASTER_0.M_NXT_ANA, FCLMST02_0.FORECLOSURE_SALE_DATE, FCLMST02_0.BANKRUPTCY_FILED_DATE, FCLMST02_0.BANKRUPTCY_DUE_DATE, FCLMST02_0.BANKRUPTCY_NOTICE_DATE, FCLMST02_0.BANKRUPTCY_TYPE, MASTER_0.M_CNTY_CD
FROM SQLDBA.MASTER MASTER_0 LEFTJOIN SQLDBA.FCLMST02 FCLMST02_0,
ON MASTER_0.M_LOAN = FCLMST02_0.LOAN
But I don't think this is correct.
Can someone PLEASE help me?? I will be forever in your debt!
Annie
I am new to using Microsoft Query, and am having lots of trouble joining two tables and getting all the results in one table.
I have two very large tables:
MASTER
has 175,000+ rows of data and about 30 columns I need
FCLMST02
has about 23,000 rows and about 4 columns that I need
I have created my query to just get the columns I need, from both tables, but when I try to JOIN them, using the instructions below, option 2 is greyed out:
- In Microsoft Query, create a query and add both tables to it.
- Join a field that matches between the two tables (for example, the Customer ID field in two customer lists) by dragging the field in the first table to the second table. Choose a field that has information for every record in each table. For example, if two customer lists have matching Customer ID fields, join the Customer ID field.
- Double-click the join line between the two tables.
- In the Joins dialog box, click option 2, click Add, and then click Close.
- Add the fields that you want to the query.
- On the View menu, click SQL.
- Select the data in the SQL statement box, press CTRL+C to copy it, and then click OK.
- Double-click the join line again.
- In the Joins dialog box, click option 3, click Add, and then click Close.
- On the View menu, click SQL.
- Click at the end of the data in the SQL statement box, press ENTER, type the capitalized word UNION and then press ENTER again.
- Press CTRL+V to paste the copied information after the word UNION.
- Click OK, and when prompted that the query can't be displayed graphically, click OK again.
Both tables contain a common field: LOAN
I want to keep all the data in the MASTER table and add all the additional columns that is in the FCLMST02 table.
Any LOAN that is also listed in the FCLMST02 table should populate their columns, and all the other rows in the MASTER table that are not in the FCLMST02 table can say Null (or whatever).
I've tried writing my own SQL statement, actually I just amended the statement created by my query:
SELECT MASTER_0.M_LOAN, MASTER_0.M_SC, MASTER_0.M_INV_NO, MASTER_0.M_LIEN, MASTER_0.M_LN_TYP, MASTER_0.M_ORIG_TRM_MTHS, MASTER_0.M_PAY_FREQ, MASTER_0.M_LATE_DAY, MASTER_0.M_LC_AMT, MASTER_0.M_LATE_CHG_BAL, MASTER_0.M_INT_RATE, MASTER_0.M_ORIG_INT_RTE, MASTER_0.M_SUS_BAL, MASTER_0.M_UNAP_FND_BAL, MASTER_0.M_MERS_MIN, MASTER_0.M_MOD_FST_PMT_DUE_MM, MASTER_0.M_MOD_FST_PMT_DUE_DD, MASTER_0.M_MOD_FST_PMT_DUE_YY, MASTER_0.M_FHA_VA_PMI, MASTER_0.M_PMI_RATE, MASTER_0.M_PRIN_BAL, MASTER_0.M_P_I, MASTER_0.M_MTHLY_ESC, MASTER_0.M_ESC_ADV_BAL, MASTER_0.M_DUE_DT, MASTER_0.M_INT_CD, MASTER_0.M_OCC_CD, MASTER_0.M_ESC_BAL, MASTER_0.M_FCL_SALE_MM, MASTER_0.M_FCL_SALE_DD, MASTER_0.M_FCL_SALE_YY, MASTER_0.M_ORIG_LN_DT, MASTER_0.M_MAT_DT, MASTER_0.M_FST_DUE_DT, MASTER_0.M_LAST_INIT_DT, MASTER_0.M_BALLOON_DT, MASTER_0.M_LAST_PAY_REC_MM, MASTER_0.M_LAST_PAY_REC_DD, MASTER_0.M_LAST_PAY_REC_YY, MASTER_0.M_LAST_ANALYSIS_MM, MASTER_0.M_LAST_ANALYSIS_DD, MASTER_0.M_LAST_ANALYSIS_YY, MASTER_0.M_MTGR_NAME, MASTER_0.M_FICO_SCORE, MASTER_0.M_MTGR_SS_NO, MASTER_0.M_MAIL_ADDR_1, MASTER_0.M_MAIL_ADDR_2, MASTER_0.M_MAIL_CITY, MASTER_0.M_MAIL_ST, MASTER_0.M_MAIL_ZIP_CD1, MASTER_0.M_MAIL_ZIP_CD2, MASTER_0.M_PROP_NO, MASTER_0.M_PROP_DIR, MASTER_0.M_PROP_STREET_NAME, MASTER_0.M_PROP_CITY, MASTER_0.M_PROP_ST, MASTER_0.M_PROP_ZIP_CD1, MASTER_0.M_PROP_ZIP_CD2, MASTER_0.M_RM_PROP_TYP, MASTER_0.M_APPR_VAL, MASTER_0.M_INDX_CD, MASTER_0.M_INDX_TYP, MASTER_0.M_NOTC_REQ, MASTER_0.M_INT_FCTR, MASTER_0.M_INT_CHG_FRQ, MASTER_0.M_RM_BEG_INDEX, MASTER_0.M_INDX_ADJ, MASTER_0.M_MAX_INT_DEC, MASTER_0.M_MAX_INT_INC, MASTER_0.M_MIN_ANUL_INT_DEC, MASTER_0.M_MIN_ANUL_INT_INC, MASTER_0.M_PREV_INT_RTE, MASTER_0.M_L_PMT_CHG_DT, MASTER_0.M_NXT_INT_CHG_DT, FCLMST02_0.CURRENT_APPRAISAL_AMT, FCLMST02_0.CURRENT_APPRAISAL_DATE, MASTER_0.M_NXT_ANA, FCLMST02_0.FORECLOSURE_SALE_DATE, FCLMST02_0.BANKRUPTCY_FILED_DATE, FCLMST02_0.BANKRUPTCY_DUE_DATE, FCLMST02_0.BANKRUPTCY_NOTICE_DATE, FCLMST02_0.BANKRUPTCY_TYPE, MASTER_0.M_CNTY_CD
FROM SQLDBA.MASTER MASTER_0 LEFTJOIN SQLDBA.FCLMST02 FCLMST02_0,
ON MASTER_0.M_LOAN = FCLMST02_0.LOAN
But I don't think this is correct.
Can someone PLEASE help me?? I will be forever in your debt!
Annie