Having this table, I would like to find the rows with Val fitting my Indata.
Tol field is a tolerance (varchar), that can be either an integer/float or a percentage value.
Row Val Tol Outdata
1 24 0 A
2 24 5 B
3 24 10 C
4 32 %10 D
5 32 1 E
Indata 30 for example should match rows 3 (24+10=34) and 4 (32-10%=28.8).
Can this be done in mySQL? CREATE FUNCTION?
I don’t have a MySQL install to test it on, but this example is converted from Oracle sql syntax. You have to use string functions to determine if the
tolis a percent and act accordingly to calculate the min and max range for that field. Then you can use a between clause.