I have columns in my table that are '123 4567890'... I need to remove the space in between the 3 and 4 so that all of my tables are the same and i can query against each of them.. and get the results.
Asked
Active
Viewed 2,571 times
-4
-
6Questions asking for code must demonstrate a minimal effort. Show us what you've tried. – Kermit Feb 03 '14 at 15:37
2 Answers
4
Try the following if you want the number without space while selecting:
select REPLACE(your_field, ' ', '')
Else, update the entire column like:
UPDATE
your_table
SET
your_field = REPLACE(your_field, ' ', '')
WHERE
your_field LIKE '% %'
References:
-2
Use
Trim() method in jaa
Or use
String str ="123 45678";
str=str.replace(" ","");
OR
StringBuilder sbr="123 4567";
sbr.replace(" ","");
In SQL: Use:
select REPLACE(your_field, ' ', '') ;

Ashish Ratan
- 2,838
- 1
- 24
- 50
-
4None of these relate to SQL or MySQL, and therefore are not applicable to this question. – Ken White Feb 03 '14 at 15:40
-
-
-
-
1It was downvoted because it was wrong, I would guess. If you post an answer here, it should be an answer to the question asked. In this case, the question is clearly tagged SQL and MySQL, and you posted nothing related to either of them in your answer. – Ken White Feb 03 '14 at 15:49
-
@KenWhite did you really think my answer is wrong yet ??? i dont think its fare, if my answer is wrong above answer shuld be also wrong man... BTW thnanks, for downvote. i realize its kinda competition here for up or down.. this time you wron – Ashish Ratan Feb 03 '14 at 16:02
-
Wait. You're making the assumption that I'm the one that downvoted. I commented, and I speculated on why I thought it had been downvoted because you asked me. However, your answer *was* wrong. If you post wrong answers, you should expect to get downvoted; that's *exactly how this site is designed to work*. And *above answer* shows two ways to do it via SQL, which is what the question asked. (And finally, people here decide whether a question should be downvoted or not. It's the choice of the voter, not yours, and they don't have to tell you they did or why they did so. That's how SO works.) – Ken White Feb 03 '14 at 16:55
-
actually dude, it has answer , by mistakenly i pressed enter :P and ans got posted, srry dude, lill misunderstanding... cos my ans was ryt still down voted, so feel lill anger that time – Ashish Ratan Feb 03 '14 at 16:59