MySql join table to a concat field
Copy link to clipboard
Copied
Hi
I have a view and within my select i have a concat statement to bring 3 fields together.
I would then like to join another table to the view which would join to the concatonated field I have made.
is this possible to do or would I need to write a second view referencing the first one to do it?
many thanks for any help
Simon

Copy link to clipboard
Copied
Do you mean, you will join another table, and a field from that table will be added to current CONCAT statement?
Also, if you could post your current SQL statement, and second table, field names you want to add etc. would help
Copy link to clipboard
Copied
Hi
Thanks for replying - I have figured it out and below is the example in case anyone searches for this another time.
I wanted to just join a new table on the new field I formed by concatonating fields.
This was my concat field
select concat_ws('_',`ut_postrace`.`race`.`BREED`,`ut_postrace`.`event`.`TRACK`,`ut_postrace`.`pool`.`POOL`) AS `RebateID`,
This is how I joined a new table to that field
join `united_tote`.`_colreb` on((concat_ws('_',`ut_postrace`.`race`.`BREED`,`ut_postrace`.`event`.`TRACK`,`ut_postrace`.`pool`.`POOL`) = convert(`united_tote`.`_colreb`.`Rebate_id` using utf8))))

