License Public Domain
Lines 20
Keywords
barcode (1) checksum (1) ean (1) ean13 (1) mysql (1) oscommerce (2) sql (1) xt:commerce (2)
Permissions
Owner: occam
Viewable by Everyone
Editable by All Siafoo Users
Hide
Siafoo is here to make coding less frustrating and to save you time. Join Siafoo Now or Learn More

EAN13 check with SQL Atom Feed 0

In Brief Verify the EAN13 Checksum with (My)SQL. Output invalid EAN Numbers.... more
# 's
 1SELECT attributes_ean
2FROM products_attributes
3WHERE
4LENGTH(attributes_ean) = 13
5AND
6SUBSTRING((10 - ((((
7SUBSTRING(attributes_ean FROM 2 FOR 1) +
8SUBSTRING(attributes_ean FROM 4 FOR 1) +
9SUBSTRING(attributes_ean FROM 6 FOR 1) +
10SUBSTRING(attributes_ean FROM 8 FOR 1) +
11SUBSTRING(attributes_ean FROM 10 FOR 1) +
12SUBSTRING(attributes_ean FROM 12 FOR 1)
13)*3) + (
14SUBSTRING(attributes_ean FROM 1 FOR 1) +
15SUBSTRING(attributes_ean FROM 3 FOR 1) +
16SUBSTRING(attributes_ean FROM 5 FOR 1) +
17SUBSTRING(attributes_ean FROM 7 FOR 1) +
18SUBSTRING(attributes_ean FROM 9 FOR 1) +
19SUBSTRING(attributes_ean FROM 11 FOR 1)
20)) MOD 10)) FROM -1 FOR 1) != SUBSTRING(attributes_ean FROM 13 FOR 1)

Verify the EAN13 Checksum with (My)SQL. Output invalid EAN Numbers.

This example is using the xt:commerce DB structure.