[英]select clause evaluates and return value from different columns of joined tables
[英]Select from two tables joined by different number of columns
我有兩張桌子。 首先,我有一個包含以下格式的字母數字的列:X12345678A(1個字母,8個數字和1個字母)。
在第二個表中,我具有相同的字段,但分為三列,第一列包含前導字母,第二列包含數字,第三列包含尾隨字母。
我的問題:如果我不能修改表結構,如何有效地連接兩個表,即使用索引?
先感謝您!
使用字符串連接:
select . . .
from t1 join
t2
on t1.col = t2.col1 || t2.col2 || t2.col3;
為了提高連接效率,您可以嘗試在t1(col)
創建索引或在表達式t2(col1 || col2 || col3)
上創建索引。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.