Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

EAN13 Check With SQL

DZone's Guide to

EAN13 Check With SQL

·
Free Resource

SELECT attributes_ean
FROM products_attributes
WHERE
LENGTH(attributes_ean) = 13
AND
SUBSTRING((10 - ((((
SUBSTRING(attributes_ean FROM 2 FOR 1) +
SUBSTRING(attributes_ean FROM 4 FOR 1) +
SUBSTRING(attributes_ean FROM 6 FOR 1) +
SUBSTRING(attributes_ean FROM 8 FOR 1) +
SUBSTRING(attributes_ean FROM 10 FOR 1) +
SUBSTRING(attributes_ean FROM 12 FOR 1)  
)*3) + (
SUBSTRING(attributes_ean FROM 1 FOR 1) +
SUBSTRING(attributes_ean FROM 3 FOR 1) +
SUBSTRING(attributes_ean FROM 5 FOR 1) +
SUBSTRING(attributes_ean FROM 7 FOR 1) +
SUBSTRING(attributes_ean FROM 9 FOR 1) +
SUBSTRING(attributes_ean FROM 11 FOR 1)
)) MOD 10)) FROM -1 FOR 1) != SUBSTRING(attributes_ean FROM 13 FOR 1)
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}