Help with MySql SELECT statement: SELECT lname, fname

Posted on 2009-07-09
Last Modified: 2013-12-13
Help with MySql SELECT statement: SELECT lname, fname

SELECT lname "," fname as 'STUDEN NAME'
FROM intenrollment
WHERE confirm = 'Y' and policyno='2008

I want the name to look like this: Anderson, Tom
Question by:Willy3g

Accepted Solution

stefanx earned 500 total points
ID: 24819264
SELECT CONCAT(lname,', ',fname) FROM intenrollment

Expert Comment

ID: 24820972
You are missing , in your query, try this :

SELECT trim(lname), ",",trim(fname) as 'STUDEN NAME'
FROM intenrollment
WHERE confirm = 'Y' and policyno='2008'

Bm keshav

LVL 18

Expert Comment

by:Sudaraka Wijesinghe
ID: 24822462
I would do it using concat also. but watch out if either lname or fname is null, the whole thing will come out as null

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP strings vs array errors 13 32
Cpanel file manager 8 40
How to set the Tinymce Editor image path 4 22
Wordpress Pagination 1 28
Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question