p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   MySQL (http://p2p.wrox.com/forumdisplay.php?f=99)
-   -   Concatination (http://p2p.wrox.com/showthread.php?t=17064)

BSkelding August 18th, 2004 01:24 PM

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?

happygv August 18th, 2004 09:47 PM

Try this.


SELECT Concat_WS(",",Firstname,Replace(MI,NULL,'NULL'),Lastname) From Customers

SELECT Concat_WS(",",Firstname,Replace(MI,NULL,''),Lastname) From Customers
- Vijay G
Strive for Perfection

All times are GMT -4. The time now is 10:51 AM.

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