function

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

function

Post by psurrena »

Is there a function that would replace the spaces in a string? Like concat but only one row.

For example: "I am a machine" would become "I,am,a,machine".

Thanks!
User avatar
Apollo
Forum Regular
Posts: 794
Joined: Wed Apr 30, 2008 2:34 am

Re: function

Post by Apollo »

$result = str_replace(" ", ",", $yourText);
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Re: function

Post by psurrena »

Thanks, but I wanted to do this in the query and not in PHP.
User avatar
EverLearning
Forum Contributor
Posts: 282
Joined: Sat Feb 23, 2008 3:49 am
Location: Niš, Serbia

Re: function

Post by EverLearning »

MySql String Functions

[sql]SELECT REPLACE("I am a machine", ' ', ',');[/sql]

Use Google. I found this by entering the following query - mysql string replace
Post Reply