Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
INET_NTOA() function in MySQL
Next article icon

INET_ATON() function in MySQL

Last Updated : 14 Dec, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

INET_ATON() :

This function in MySQL takes the dotted-quad representation of an IPv4 address as a string and returns the numeric value of the given IP address in form of an integer. If the input address is not a valid IPv4 address this function returns NULL. The return address is calculated by the following formula :

If the given input IPv4 address is a.b.c.d then the return value a×2563+ b×2562+ c×2561 + d

Syntax :

INET_ATON(expr)

Parameter : 

This method accepts only one parameter.

  • expr – Input IPv4 address represented by a string.

Returns : 

It returns the numeric value of a given IPv4 address.

Example-1 :

Checking the equivalent integer representation for the following address “1.6.5.0” with the help of INET_ATON Function. As it is a valid IPv4 address we will get results in an integer.

SELECT INET_ATON('1.6.5.0')  AS AddressInInteger ;

Output :

ADDRESSININTEGER
17171712

Example-2 :

Checking the equivalent integer representation for the following address “::1.6” with the help of INET_ATON Function. As it is not a valid IPv4 address we will get NULL.

 SELECT INET_ATON('::1.6')  AS AddressInInteger ;

Output :

ADDRESSININTEGER
NULL

Example -3 :

Checking the equivalent integer representation for the following address “115.16.55.255” with the help of INET_ATON Function. As it is a valid IPv4 address we will get results in an integer.

 SELECT INET_ATON('15.16.55.255')  AS AddressInInteger ;

Output :

ADDRESSININTEGER
252721151

Example-4 :

Checking the equivalent integer representation for the following IPv6 address “fdfe::5a55:caff:fefa:9089” with the help of INET_ATON Function. 

SELECT INET_ATON('fdfe::5a55:caff:fefa:9089')  AS AddressInInteger ;

Output :

ADDRESSININTEGER
NULL


Next Article
INET_NTOA() function in MySQL
author
jana_sayantan
Improve
Article Tags :
  • SQL
  • DBMS-SQL
  • mysql

Similar Reads

  • INET6_ATON() function in MySQL
    This function in MySQL takes a dotted representation of an IPv4 or IPv6 address and returns a binary string that represents the numeric value of the address in network byte order. If the input address is not a valid IPv4 or IPv6 address this function returns NULL. Syntax : INET6_ATON(expr) Parameter
    2 min read
  • INSERT() function in MySQL
    INSERT() : This function in MySQL is used for inserting a string within a string, removing a number of characters from the original string. Syntax : INSERT(str, pos, len, newstr) Parameters : This method accepts four parameter. str - Original string in which we want to insert another string. pos - T
    2 min read
  • LEFT() Function in MySQL
    The LEFT() function in MySQL is used to extract a specified number of characters from the left side of a given string. It uses its second argument to decide, how many characters it should return. Syntax: LEFT (str, len)Parameter: This function accepts two parameters as mentioned above and described
    1 min read
  • INET_NTOA() function in MySQL
    INET_NTOA() : This function in MySQL takes the IPv4 address in network byte order and then it returns the address as a dotted-quad string representation. This function returns NULL if the input address is an invalid IPv4 address. Syntax : INET_NTOA(expr) Parameter : This function accepts only one pa
    2 min read
  • LN() Function in MySQL
    LN() function : It is the function in MySQL is used to calculate the natural logarithm of a specific number with base e . The number must be greater than 0, otherwise it will return NULL. Syntax : LN(X) Parameter : LN() function accepts one parameter as mentioned above in the syntax and described be
    2 min read
  • COUNT() Function in MySQL
    The COUNT() function in MySQL is a versatile aggregate function used to determine the number of rows or non-NULL values that match a specific condition in a query. It can be applied to an entire table or a particular column and is widely used in database operations to analyze the volume of data in a
    3 min read
  • LEAST() Function in MySQL
    The LEAST() function in MySQL is a versatile tool that returns the smallest (minimum) value from a list of expressions. It can be used with numbers, strings, or even columns of data to find the minimum value according to their data type. In this article, We will learn about LEAST() Function in MySQL
    4 min read
  • INET6_NTOA() function in MySQL
    INET6_NTOA() : This function in MySQL takes an IPv6 or IPv4 network address represented in numeric form as a binary string and it returns the string representation of the address as a string in the connection character set. It returns NULL if the address is not valid. Syntax : INET6_NTOA(expr) Param
    2 min read
  • MONTH() function in MySQL
    MySQL MONTH() function returns the month from the given date. It returns a month value between 1 and 12 or returns 0 when the month part of the date is 0. It's a useful SQL function for date manipulation and analysis, particularly when dealing with reports or queries that require month-based groupin
    3 min read
  • BIT_LENGTH() Function in MySQL
    BIT_LENGTH() function in MySQL is used to find the length of a given string in bits. The input string can be a character string or number string. Syntax : BIT_LENGTH(str) Parameter : Required. str : A string whose bits length to be calculated. Returns : It returns the length of a given string in bit
    1 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences