Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 18th, 2004, 01:24 PM
Authorized User
 
Join Date: Mar 2004
Location: Maumee, OH, USA.
Posts: 61
Thanks: 0
Thanked 0 Times in 0 Posts
Default Concatination

I have a query that selects fields from the database and places a seperator between each field. For example:

SELECT Concat_WS(",",Firstname,MI,Lastname) From Customers

The problem is that if MI is blank it does not write a comma signifying that there is another field that does not contain any data. Is there a way to solve this?
Reply With Quote
  #2 (permalink)  
Old August 18th, 2004, 09:47 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this.

Code:
SELECT Concat_WS(",",Firstname,Replace(MI,NULL,'NULL'),Lastname) From Customers
OR
Code:
SELECT Concat_WS(",",Firstname,Replace(MI,NULL,''),Lastname) From Customers
_________________________
- Vijay G
Strive for Perfection
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PLS HELP ME ..STRING CONCATINATION rajukurian SQL Language 15 May 6th, 2005 05:47 PM
Concatination kilika SQL Server 2000 1 August 26th, 2003 10:44 AM



All times are GMT -4. The time now is 05:45 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.