Reputation: 2860
the following query is not working in MYSql (a Trigger)
set new.uniq = SUBSTR(md5(concat(new.lat, '-', new.lon)),0,5)
only if i delete the SUBSTR it will give me an correct output
set new.uniq = md5(concat(new.lat, '-', new.lon))
Upvotes: 0
Views: 598
Reputation: 26343
The problem is the zero:
set new.uniq = SUBSTR(md5(concat(new.lat, '-', new.lon)),0,5)
^
For example:
SELECT SUBSTR('whatever', 0, 5) --> returns empty string
SELECT SUBSTR('whatever', 1, 5) --> returns 'whate'
Change the zero to a 1 and you should be fine:
set new.uniq = SUBSTR(md5(concat(new.lat, '-', new.lon)),1,5)
Upvotes: 1