*Table name: cvmorans
All columns are varchar
farmno has data like 002004, 006007,003456
honum has data like 001,004,006
lotno has data like 10,25,78
Task 1 - substitute the 3 character of farmno with a, "F" if 3, "N" if
6, otherwise, no substitution
Task 2 - CONCAT right(farmno,4),right(honum,1), lotno
End result for the above samples:
F004110
N007425
3456678
And I have made an attempt (successful, but not completely what I
need)
select if(substr(farmno,3,1) = 2,
concat('F',right(farmno,3),right(honum,1),lotno),
concat('N',right(farmno,3),right(honum,1),lotno))
as lotnumber from cvmorans
This will only substitute for a 2 or 6 in the 3rd position.
Can I use an IF inside ...*

## Bookmarks