I have a client word database and I am attempting to create a database with
the results from a select that splits the description field based on the
spaces.
When just executing the select command, the output is correct. When using
the create command with the select command, apparently the IF statement
result (0/1) is being placed into the field instead of the word.
My Mysql version is: mysql Ver 12.12 Distrib 4.0.3-beta, for pc-linux-gnu
(i686)
clientid description
-------- -----------------
client1 chair couch piano
client2 bed dresser
client3 chair
client4 table stove couch
drop table if exists wordsplit;
####create table wordsplit
select clientid,
if(locate(' ',description)=0,trim(substring(description,1)),
trim(substring(description,1,locate(' ',description)))) as firstword,
if(locate(' ',trim(substring(description,locate(' ',description))))=0,
substring(trim(substring(description,locate(' ',description))),1),
substring(trim(substring(description,locate(' ',description))),1,
locate(' ',trim(substring(description,locate(' ',description)))))) as
secondword,
(trim(substring(ltrim(substring(description,locate(' ',description))),
locate(' ',ltrim(substring(description,locate(' ',description))))))) as
thirdword
from clientword order by clientid;
Any help appreciated
Scotty
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php