We help IT Professionals succeed at work.

MySQL Query combine two columns in PHP

pda4me
pda4me asked
on
Medium Priority
467 Views
Last Modified: 2012-06-27
I am using the following MySQL query in PHP.  How do I combine the values in each record for StreetNu and StreetNa into a single column of data using this query?  Right now it splits them out as two seperate columns.

SELECT  MLNumber AS Home_ID, StreetNu AS StreetNumber, StreetNa AS StreetName City AS City, State AS State, ZipCode AS zip, MarketingRemarks AS description, SubdivisionDisplay AS neighborhood, ListingPrice AS price, VirtualTourURL AS virtual_tour_1, Bedrooms AS bedrooms, Bathrooms AS bathrooms_full, SquareFootage AS living_area FROM MyTable
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
select CONCAT(StreetNu , ' ', StreetNa ) streetinfo from mytable

Author

Commented:
that does not work when I try to insert into the existing sql statement?

to be more clear I need StreetNu and StreetNa to be a column (AS) called StreetInfo just like the other column treatments you see.
Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009
Commented:
ok, full code
SELECT  MLNumber AS Home_ID, CONCAT(StreetNu, ' ', StreetNa) AS FullStreetAddress,City AS City, State AS State, ZipCode AS zip, MarketingRemarks AS description, SubdivisionDisplay AS neighborhood, ListingPrice AS price, VirtualTourURL AS virtual_tour_1, Bedrooms AS bedrooms, Bathrooms AS bathrooms_full, SquareFootage AS living_area FROM MyTable

Open in new window

Author

Commented:
thanks!

Explore More ContentExplore courses, solutions, and other research materials related to this topic.