Posted By

occam on 08/05/09


Tagged

sql oscommerce barcode EAN13 EAN xtcommerce


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

dantreacy


EAN13 Check


 / Published in: MySQL
 

This verify's the checksum of a EAN13 barcode.

  1. SELECT attributes_ean
  2. FROM products_attributes
  3. WHERE
  4. LENGTH(attributes_ean) = 13
  5. AND
  6. SUBSTRING((10 - ((((
  7. SUBSTRING(attributes_ean FROM 2 FOR 1) +
  8. SUBSTRING(attributes_ean FROM 4 FOR 1) +
  9. SUBSTRING(attributes_ean FROM 6 FOR 1) +
  10. SUBSTRING(attributes_ean FROM 8 FOR 1) +
  11. SUBSTRING(attributes_ean FROM 10 FOR 1) +
  12. SUBSTRING(attributes_ean FROM 12 FOR 1)
  13. )*3) + (
  14. SUBSTRING(attributes_ean FROM 1 FOR 1) +
  15. SUBSTRING(attributes_ean FROM 3 FOR 1) +
  16. SUBSTRING(attributes_ean FROM 5 FOR 1) +
  17. SUBSTRING(attributes_ean FROM 7 FOR 1) +
  18. SUBSTRING(attributes_ean FROM 9 FOR 1) +
  19. SUBSTRING(attributes_ean FROM 11 FOR 1)
  20. )) MOD 10)) FROM -1 FOR 1) != SUBSTRING(attributes_ean FROM 13 FOR 1)

Report this snippet  

You need to login to post a comment.