• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 375
  • Last Modified:

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

0
LZ1
Asked:
LZ1
1 Solution
 
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
 
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now