我在这里有此代码,该代码从想要的列中选择13个字符:
`select barcode, substring(barcode,1,13) as test from outerbarcodes
我需要选择前13个字符并将其与另一个表连接。但是我不想创建一个新表然后加入。在Workbench中显示结果的方式是什么?
我尝试了以下方法:
`select barcode, substring(barcode,1,13) as test from outerbarcodes join bridgeb on
`outerbarcodes.test = bridgeb.barcode
答案 0 :(得分:0)
select barcode, substring(barcode,1,13) as test from outerbarcodes join bridgeb on
outerbarcodes.test = bridgeb.barcode
ON
,WHERE
子句中不能使用选择别名,选择别名只能在HAVING
子句中使用
您需要做
select barcode, substring(barcode,1,13) as test from outerbarcodes join bridgeb on
substring(barcode,1,13) = bridgeb.barcodes
或
select barcode, test from (
select barcode, substring(barcode,1,13) as test from outerbarcodes
) as outerbarcodes join bridgeb on
outerbarcodes.test = bridgeb.barcodes