Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with MySql SELECT statement: SELECT lname, fname

Posted on 2009-07-09
3
Medium Priority
?
749 Views
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
0
Comment
Question by:Willy3g
3 Comments
 
LVL 8

Accepted Solution

by:
stefanx earned 2000 total points
ID: 24819264
SELECT CONCAT(lname,', ',fname) FROM intenrollment
0
 
LVL 6

Expert Comment

by:BALMUKUND KESHAV
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

0
 
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
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

963 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