Index a virtual column created with CONCAT for use in mysql JOINs

Is there some way to index a virtual column created with CONCAT for use in mysql JOINs?

If so, how?

Why would you want to join on concatenated fields instead of the actual field values? :shifty:

Convenience. That’s what I do now.

Mysql has lots of capabilities that I don’t use. Just scratching that that itch.

i doubt it… can you show your sample join sql please?

SELECT 
t1.id
FROM    
tbl1 AS t1
JOIN 
tbl2 AS t2
ON  
 CONCAT(t1.var2, t1.var3) = CONCAT(t2.var2, t2.var3)

why can’t you just say

    ON t1.var2 = t2.var2
   AND t1.var3 = t2.var3
2 Likes

No good reason except that I got it in my head to use CONCAT.

Many thanks for answering my question r937.