If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Help required, to complex for this newbie

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-03-06, 06:57
stargate03 stargate03 is offline
Registered User
 
Join Date: Dec 2006
Posts: 2
Help required, to complex for this newbie

Hi there

I have a MYSQL database which has the following table


CREATE TABLE `#__content` (
`id` int(11) unsigned NOT NULL auto_increment,
`title` varchar(100) NOT NULL default '',
`title_alias` varchar(100) NOT NULL default '',
`introtext` mediumtext NOT NULL,
`fulltext` mediumtext NOT NULL,
`state` tinyint(3) NOT NULL default '0',
`sectionid` int(11) unsigned NOT NULL default '0',
`mask` int(11) unsigned NOT NULL default '0',
`catid` int(11) unsigned NOT NULL default '0',
`created` datetime NOT NULL default '0000-00-00 00:00:00',
`created_by` int(11) unsigned NOT NULL default '0',
`created_by_alias` varchar(100) NOT NULL default '',
`modified` datetime NOT NULL default '0000-00-00 00:00:00',
`modified_by` int(11) unsigned NOT NULL default '0',
`checked_out` int(11) unsigned NOT NULL default '0',
`checked_out_time` datetime NOT NULL default '0000-00-00 00:00:00',
`publish_up` datetime NOT NULL default '0000-00-00 00:00:00',
`publish_down` datetime NOT NULL default '0000-00-00 00:00:00',
`images` text NOT NULL,
`urls` text NOT NULL,
`attribs` text NOT NULL,
`version` int(11) unsigned NOT NULL default '1',
`parentid` int(11) unsigned NOT NULL default '0',
`ordering` int(11) NOT NULL default '0',
`metakey` text NOT NULL,
`metadesc` text NOT NULL,
`access` int(11) unsigned NOT NULL default '0',
`hits` int(11) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `idx_section` (`sectionid`),
KEY `idx_access` (`access`),
KEY `idx_checkout` (`checked_out`),
KEY `idx_state` (`state`),
KEY `idx_catid` (`catid`),
KEY `idx_mask` (`mask`)
) TYPE=MyISAM;



What i need to do is insert certain data from a text file in the format

#TITLE#Important Checklist For Starting A Business#/TITLE#
some text is here
#BREAK#
#TITLE#Building An Online Business Is Like Starting A Garden, You First Must Plant Your Seeds#/TITLE#
another lot of text here
#BREAK#


into the title, introtext (first 300 chracters of "some text is here etc") and fulltext (rest of "some text is here etc") fields, also the id field needs to increment


could someone write a script etc of what needs to happen, or is there some software that makes it easier, as i am just a beginner

many thanks
Reply With Quote
  #2 (permalink)  
Old 12-03-06, 08:40
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
use LOAD DATA INFILE. only load the title and full text fields. then use an UPDATE to select 300 characters to put in the introtext field.

when you use LOAD DATA INFILE you can specify your field separators as well as the specific columns you want inserted into.

also do yourself a favour and rename that table, get rid of the # and underscores. sooner or later it is going to cause you trouble.
Reply With Quote
  #3 (permalink)  
Old 12-03-06, 12:06
stargate03 stargate03 is offline
Registered User
 
Join Date: Dec 2006
Posts: 2
confused

i tried that but everytime i get a 1064 error

could someone provide me with the correct syntax

thanks
Reply With Quote
  #4 (permalink)  
Old 12-03-06, 15:20
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
show us your sql query then and we can help you modify it. the 1064 error message would actually pinpoint the error for you as well so post that error message too.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On