Click here to Skip to main content
11,703,632 members (66,491 online)
Rate this: bad
good
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 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
0 Maciej Los 570
1 OriginalGriff 510
2 Sergey Alexandrovich Kryukov 430
3 Andy Lanng 249
4 CPallini 195
0 OriginalGriff 8,744
1 Sergey Alexandrovich Kryukov 7,747
2 CPallini 5,107
3 Maciej Los 4,716
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 14 Nov 2010
Copyright © CodeProject, 1999-2015
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