Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 20th, 2011, 06:01 AM
Authorized User
 
Join Date: Jul 2011
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default storing images in database

hi all,
i want to store an image in MYSQL database.please tell me whether the below sql syntax i have written is correct or not.
Code:
CREATE TABLE IF NOT EXISTS `products`(
  `serial` int(11) NOT NULL auto_increment,
  `name` varchar(20) collate latin1_general_ci NOT NULL,
  `description` varchar(255) collate latin1_general_ci NOT NULL,
  `price` float NOT NULL,
  `picture` varchar(80) collate latin1_general_ci NOT NULL,
  PRIMARY KEY(`serial`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=7;
and i have inserted the values for the above table also.
below is the one.....
Code:
INSERT INTO `products` (`serial`, `name`, `description`, `price`, `picture`) VALUES
(1, 'View Sonic LCD', '19" View Sonic Black LCD, with 10 months warranty', 250, 'images/lcd.jpg'),
(2, 'IBM CDROM Drive', 'IBM CDROM Drive', 80, 'images/cdrom-drive.jpg'),
(3, 'Laptop Charger', 'Dell Laptop Charger with 6 months warranty', 50, 'images/charger.jpg'),
(4, 'Seagate Hard Drive', '80 GB Seagate Hard Drive in 10 months warranty', 40, 'images/hard-drive.jpg'),
(5, 'Atech Mouse', 'Black colored laser mouse. No warranty', 5, 'images/mouse.jpg'),
(6, 'Nokia 5800', 'Nokia 5800 XpressMusic is a mobile device with 3.2" widescreen display brings photos, video clips and web content to life', 299, 'images/mobile.jpg');
the "picture" field stores pictures in database.i have given there VARCHAR(80)
i know for storing pictures we should give BLOB data type.
but tell me whether the above syntax i have written will work or not.
if not what would be the syntax...
 
Old August 21st, 2011, 01:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

well didnt u run it to see the result?
what i see is inserting image paths to a varchar field
__________________
Always,
Hovik Melkomian.
 
Old August 22nd, 2011, 03:26 AM
Authorized User
 
Join Date: Jul 2011
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default reply

no it is not displaying the image..
 
Old August 23rd, 2011, 01:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

O sure it wouldnt! where do u wanna show ur pic? & what is ur application?
its a string (address if ur image)
__________________
Always,
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing images in Database and displaying them Manoj Bisht ASP.NET 1.x and 2.0 Application Design 4 February 6th, 2010 03:06 AM
Load Images from and Save Images to a Database cyndie VB.NET 2 August 17th, 2008 06:42 AM
Storing Images into database usprasad_m SQL Server 2000 4 May 17th, 2007 05:16 PM
STORING IMAGES & EXPORTING SQLSERVER TABLES harsh_hot MySQL 2 September 8th, 2005 02:10 AM
Storing Images In Oracle & Manipulate Through VB 6 tutul128 Beginning VB 6 1 August 2nd, 2004 03:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.