Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Help with MySql SELECT statement: SELECT lname, fname

Posted on 2009-07-09
3
Medium Priority
?
745 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

When table data gets too large to manage or queries take too long to execute the solution is often to buy bigger hardware or assign more CPUs and memory resources to the machine to solve the problem. However, the best, cheapest and most effective so…
In this article, we’ll look at how to deploy ProxySQL.
The viewer will learn how to count occurrences of each item in an array.
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.

715 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