mysql - substring of a column from another SQL -
i have following table. +--------------------+-----+ |fardet_cd_fare_basis|part2| +--------------------+-----+ | meo00rig| 00r| | meo00rig| rig| | meo00rig| i| +--------------------+-----+ i need extract "fartdet_cd_fare_basis" first part of chain until appearance of "part2", example be: +--------------------+-----+--------+ |fardet_cd_fare_basis|part2| num| +--------------------+-----+--------+ | meo00rig| 00r| meo| | meo00rig| rig| meo00| | meo00rig| i| meo00ri| +--------------------+-----+--------+ i'm working spark sql, used sql solution. ideas? i think understand want. try this. livedemo select fardet_cd_fare_basis,part2, substr( fardet_cd_fare_basis, 1, instr(fardet_cd_fare_basis,part2)-1 ) der_sub your_table output +----------------------+--------+---------+ | fardet_cd_fare_basis | part2 | d...