In this tutorial we have created a table in MySQL database and then used the query to insert the data into it. This tutorial teaches you to use the query to insert the data into database.
The video of this tutorial show you how you can insert the image into database and then see it using the MySQL editing tool.
Here is the video tutorial of "How to insert image in MySQL database using sql query?":
So, lets start:
Step 1: Create MySQL Table
We are creating a mysql table with a blob type field in it, so that we can save image in it.
In our table we have only two fields:
1) image_id of int type
2) image of blog type
Here is the query to create table:
CREATE TABLE pictures (
image_id int(10) NOT NULL auto_increment,
PRIMARY KEY (`image_id`)
Step 2: insert image into table
Now we can insert the image into table using the insert into sql. Following is the example of sql:
INSERT INTO pictures VALUES(1, LOAD_FILE('d:\\flower.gif'));
We have used the LOAD_FILE() function of MySQL to insert the image data into database.
After inserting the data you can view it using the MySQL tool.
Check more tutorials at MySQL tutorials section.
Posted on: February 15, 2016 If you enjoyed this post then why not add us on Google+? Add us to your Circles