Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

append 2 or more fields in a select statement

Status
Not open for further replies.

justride

Programmer
Jan 9, 2004
251
US
Hi,

How can I append 2 or more fields in a select statement.

ex:
Code:
SELECT *, `RESTPHONE1`+`RESTPHONE2`+`RESTPHONE3` AS NUMBER FROM RESTAURANTS
I want a string of 9 digits. ###.###.####

Thanks
 
select *, concat(RESTPHONE1,"-",RESTPHONE2,"_",RESTPHONE3)...


select *, concat_ws("-",RESTPHONE1,RESTPHONE2,,RESTPHONE3)...


the _WS stands for with separator so you can define the separator first and then its just plugs them in.




Bastien

Cat, the other other white meat
 
Thanks dude, that was what i was looking for!
 
One more question,
will something like this work...
Code:
select *, FROM RESTAURANTS WHERE concat(RESTPHONE1,RESTPHONE2,RESTPHONE3) = '$number'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top