DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Database Bottlenecks Nobody Talks About: Optimizing SQL Queries Beyond Indexing
  • Why SQL Server Applications Break on PostgreSQL and How Compatibility Layers Fix It
  • Scaling Row-Level Security With ABAC on Databricks Unity Catalog
  • Seeding Postgres When Your Schema Has Foreign-Key Cycles

Trending

  • From Data Movement to Local Intelligence: The Shift from Centralized to Federated AI
  • AI in SRE: A Practical Autonomy Model for Self-Healing Infrastructure
  • DevOps Consultant vs. DevOps Employee
  • A Step-by-Step Guide to Implementing Columnar Tables in SQL Server
  1. DZone
  2. Data Engineering
  3. Databases
  4. EAN13 Check With SQL

EAN13 Check With SQL

By 
Snippets Manager user avatar
Snippets Manager
·
Aug. 05, 09 · Code Snippet
Likes (0)
Comment
Save
Tweet
Share
1.4K Views

Join the DZone community and get the full member experience.

Join For Free

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)
sql

Opinions expressed by DZone contributors are their own.

Related

  • Database Bottlenecks Nobody Talks About: Optimizing SQL Queries Beyond Indexing
  • Why SQL Server Applications Break on PostgreSQL and How Compatibility Layers Fix It
  • Scaling Row-Level Security With ABAC on Databricks Unity Catalog
  • Seeding Postgres When Your Schema Has Foreign-Key Cycles

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook