Click here to Skip to main content
12,452,015 members (33,371 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: PHP MySQL
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 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160826.1 | Last Updated 14 Nov 2010
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100