0

I'm using mysql Ver 14.14.I have created a mysql table with the attributes id, image_name and myimage.

table "unstruct_tab1" description

"myimage" is a column to hold image location. Am trying to insert image location using the following syntax.

mysql> insert into unstruct_tab1 (id,image,myimage) select 11, 'kola3.jpg' , BulkColumn from Openrowset(Bulk 'Linux path of image location...', Single_BLOB) as img;

Am ending up with the following error for the above syntax:

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(Bulk 'Linux location...', BLOB) as img' at line 1

Kindly help me out to resolve the issue.

Thomas G
  • 9,886
  • 7
  • 28
  • 41
swathi
  • 11
  • 5

1 Answers1

0

I think that syntax is for SQL server.

In MySQL, use LOAD_FILE:

insert into unstruct_tab1 (id, image, myimage) 
values(11, 'kola3.jpg', load_file('Linux path of image location'));
Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76
  • When i try the above syntax. mysql> insert into unstruct_tab1 (id, image_name, myimage) values(100, 'kola_100.jpg', load_file('Linux path..')); "myimage" column is stored as ' null ' – swathi Feb 09 '17 at 13:26
  • @swathi - You probably don't have privileges. [Check this out](http://stackoverflow.com/questions/18069054/mysql-load-file-loads-null-values) – Gurwinder Singh Feb 09 '17 at 13:33
  • Is there any other way to load image in the mysql table ? – swathi Feb 09 '17 at 13:33
  • privileges regarding Mysql version or it could be cluster ? – swathi Feb 09 '17 at 13:35
  • @swathi - Please check the question - http://stackoverflow.com/questions/18069054/mysql-load-file-loads-null-values – Gurwinder Singh Feb 09 '17 at 13:36