Jump to content


Photo

ConCat help


  • Please log in to reply
3 replies to this topic

#1 bach

bach
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 19 October 2006 - 09:41 PM

I have the following SELECT statement
SELECT s_name, s_firstname, CONCAT_WS('-', LEFT(s_phone, 4), MID(s_phone, 5, 3), RIGHT(s_phone, 4)) 
FROM `bridgend`.`sam`
ORDER BY s_name asc;

When displaying s_phone nothing is displayed on the my site.  s_name and s_firstname is displayed would I somehow have to put concat_ws in a temp variable so I can display it on my site.

Regards

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 19 October 2006 - 10:11 PM

I'm not sure what you getting at... if you display s_phone, no concat, do you get the expected output (minus formatting)?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#3 bach

bach
  • Members
  • PipPip
  • Member
  • 16 posts

Posted 20 October 2006 - 12:41 PM

yes if I display s_phone I get the data but not in the format, so my queryis how do I get the format out of the query ??

#4 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 20 October 2006 - 12:54 PM

Put an alias on the column
eg:
SELECT ..., CONCAT(....) AS phone_frmt
echo $row['phone_frmt'];





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users