How to store location in database
- how to store location in database
- how to store location in database mysql
- how to store address in database
- how to save location in database
How to store international addresses in a database
Design address database...
How to store coordinates in MySQL
Many times we capture the geo-location of users and store in the database for different use cases. I have seen that most of the developers use multiple fields to store the latitude and longitude separately like .
In this short article we will see an alternative way of storing coordinates in MySQL database using the spatial data types like .
Create a table
- Let us create a table named .
- Field of data type .
Insertion of coordinates
- To insert/update the field , we need to prepare a string like this .
- Then we will use the in-built function called to create a geometry in given SRID from WKT specification.
- Pass the prepared string of points into function.
Table will store and display the data in the following way
Also, check this out to know how to capture user's geo-location in web browser.
Thank you for reading 🙏
If you enjoyed this article or found it helpful, give it a thumbs-up 👍
Feel free to connect 👋
Twitter | Instagram | LinkedIn
- how to store location in db
- how to store gps location in database