I am trying to emulate a Vlookup by joining tables together if they share the same string. However every field that I include is prompting the enter parameter box to appear and I cannot understand why. Below I have the two tables that I need to get data from. Please note that there are some fields that I do not require for this query so have been filled in with dummy data.
Details
| SourceCode | F1 | F2 | NewMinorCat |
|---|---|---|---|
| 1077 | test | test | UNP |
| 5141 | test | test | GUU |
| 887 | test | test | XPR |
| 584 | test | test | FGG |
| 444 | test | test | IIU |
| 5141 | test | test | GUU |
Leads
| date_value | Booked_vist | Completed_visit | marketing_event_id |
|---|---|---|---|
| 01/01/2022 | test | test | 5141 |
| 10/02/2022 | test | test | 444 |
| 30/04/2022 | test | test | 887 |
| 05/03/2022 | test | test | 887 |
| 17/07/2021 | test | test | 1077 |
I am aiming to get the NewMinorCat placed into the rows where the SourceCode and marketing_event_id match. Something like this structure:
Output
| date_value | marketing_event_id | NewMinorCat |
|---|
The code I've got so far through looking around for solutions that I have then changed.
SELECT Leads.marketing_event_id, Details.SourceCode, Details.NewMinorCat
FROM Leads AS T1 LEFT OUTER JOIN Details as T2
ON T1.marketing_event_id = T2.SourceCode
I imagine that it is an oversight on my part but for the life of me I cannot see why it will work with one DB but not with the one I need.
Any help with this would be greatly appreciated.
CodePudding user response:
T1.market_event_id is a column that does not exists (it's called "marketing_event_id" in your example)
