hoverinc Posted February 3, 2011 Share Posted February 3, 2011 Hello everybody, I am trying to insert in the letter field the first letter of the FILEDX's content, How can i do it??? Any ideas is most appreciated, thanks Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/ Share on other sites More sharing options...
awjudd Posted February 3, 2011 Share Posted February 3, 2011 Use mysql's LEFT function (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_left)? ~judda Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/#findComment-1169376 Share on other sites More sharing options...
hoverinc Posted February 3, 2011 Author Share Posted February 3, 2011 Use mysql's LEFT function (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_left)? ~judda THANKS Juddster, i have checked that and worked SELECT LEFT(names, 1)from test Now i will to find out how to insert it again to it's corrisponding field using UPDATE because the other fields contains data, if you have idea regarding during my checkup i would be thankful. Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/#findComment-1169391 Share on other sites More sharing options...
ManiacDan Posted February 3, 2011 Share Posted February 3, 2011 There's nothing else we can tell you aside from writing the query for you. UPDATE someTable SET field2 = LEFT(field1, 1); Also, there's no reason to ever do this, you're duplicating data and you'll only make it hard on yourself. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/#findComment-1169397 Share on other sites More sharing options...
hoverinc Posted February 3, 2011 Author Share Posted February 3, 2011 Use mysql's LEFT function (http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_left)? ~judda AND ALSO i found this SELECT SUBSTRING(FIELD,1,1) do a similar thing Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/#findComment-1169417 Share on other sites More sharing options...
hoverinc Posted February 3, 2011 Author Share Posted February 3, 2011 There's nothing else we can tell you aside from writing the query for you. UPDATE someTable SET field2 = LEFT(field1, 1); Also, there's no reason to ever do this, you're duplicating data and you'll only make it hard on yourself. -Dan Thanks that worked perfectly Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/#findComment-1169419 Share on other sites More sharing options...
hoverinc Posted February 3, 2011 Author Share Posted February 3, 2011 I noted that this code is giving me error, any ideas is appreciated DELETE * FROM TABLE WHERE catid !='40' or may be i am missing some commands related Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/#findComment-1169447 Share on other sites More sharing options...
awjudd Posted February 3, 2011 Share Posted February 3, 2011 DELETE FROM TABLE WHERE catid != 40 There is no such thing as DELETE * FROM ... ~judda Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/#findComment-1169453 Share on other sites More sharing options...
hoverinc Posted February 3, 2011 Author Share Posted February 3, 2011 DELETE FROM TABLE WHERE catid != 40 There is no such thing as DELETE * FROM ... ~judda Yes, corrected it and worked, thanks Quote Link to comment https://forums.phpfreaks.com/topic/226563-how-to-take-the-first-letter-and-insert-it-in-another-field/#findComment-1169460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.