PHP/MySQL select drop down menu

Hey Experts!!

I am very very new to PHP and I can't get this working.  I'm trying to concatenate two columns from a MySQL table.  The concatenated item is not showing up but the values are.  

Just need help with the concatenation
SELECT Concat ( cat_sub.Category, ' - ', cat_sub.Subgroup ), cat_sub.catsub_id
FROM Cat_Sub
ORDER BY Category, Subgroup ASC

Open in new window

LVL 30
LZ1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nasirbestCommented:
Use "AS", to assign new name to resulted value
SELECT Concat ( cat_sub.Category, ' - ', cat_sub.Subgroup ) AS Category_Subgroup, cat_sub.catsub_id
FROM Cat_Sub
ORDER BY Category, Subgroup ASC

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Avinash ZalaWeb ExpertCommented:
Try attached code:

use AS key word in to get the formatted value with other name:

AS keyword is used to create a alias of the table or the field.

Hope this helps
Addy

SELECT Concat ( cat_sub.Category, ' - ', cat_sub.Subgroup ) AS newstring, cat_sub.catsub_id
FROM Cat_Sub
ORDER BY Category, Subgroup ASC

Open in new window

0
arunc85Commented:
Hi,

I think your query was correct if you are not using multiple tables.The problem for you is use the correct
table name and coulmn name.
0
LZ1Author Commented:
I had no idea I needed to throw the "as" in there.
Worked like a charm, thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.