Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHPMySQL
Hi all
 

Consider a table name PERSONS fields are p_id,p_name,p_area_code_p_phone.
 

p_id, p_name p_area_code p_phone. p_state
1 Shiana 00178 0002258965 punjab
2 Mandeep 00156 0000221996 punjab
3 Mehak 00159 0002218114 himachal
4 Rohit 00269 0000221206 Rajasthan
5 Raman 45285 2589994566 punjab
 
Now look at p_area_code and p_phone number
1. I need to concatenate the values of p_area_code and p_phone in one field which is p_phone
 
2.I need to remove all leading zero's(if any) where p_country is equal to punjab.
Posted 13-Nov-10 18:32pm
Comments
Abhinav S at 14-Nov-10 1:11am
   
Are these values stored as strings or numbers?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Assuming both are stored as string -
select CONCAT( p_area_code,p_phone) as p_phone.
 
If they are both stored as numbers then you will need to additionally convert these numbers to strings use the CONVERT function.
  Permalink  
Comments
shiana87 at 14-Nov-10 1:44am
   
dis is fine for concatination thanks ..... but I need to remove all leading zero's(if any) where p_country is equal to punjab.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,398
1 OriginalGriff 508
2 Manas Bhardwaj 383
3 Damith Weerasinghe 330
4 Tadit Dash 310
0 Sergey Alexandrovich Kryukov 9,575
1 OriginalGriff 6,006
2 Peter Leow 4,500
3 Maciej Los 3,540
4 Abhinav S 3,513


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 14 Nov 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid