Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 232545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:01:36+00:00 2026-05-11T20:01:36+00:00

I have PHP 5 code accessing a MyISAM table on MySQL 5 server. The

  • 0

I have PHP 5 code accessing a MyISAM table on MySQL 5 server. The query looks like this:

SELECT CONCAT(fName1,' ',mName2,' ',lName3) AS userName 
    FROM users 
    WHERE level > 10

When there’s no mName filled in, I am expecting output like “fname lname” , but I’m getting “” (empty string) instead (the number of rows returned is correct). Where am I making a mistake?

PHP code:

<?php
$result = mysql_query($the_above_query);
while ($result_row = mysql_fetch_assoc($result)) {
    // do stuff with the name
    // except I'm getting empty strings in $result_row['userName']
}

Relevant part of table structure:

CREATE TABLE users {
    /* -snip- */ 
    `fName1` varchar(50) default NULL,      
    `mName2` varchar(50) default NULL,      
    `lName3` varchar(50) default NULL,      
    `level` int(11) default 0,      
    /* -snip- */ 
} ENGINE=MyISAM DEFAULT CHARSET=utf8;

(also, is this way (column concatenation in MySQL) a good idea, or should I fetch the columns to PHP and join them there?)


Turns out that I was getting back a NULL; PHP treats a returned NULL and empty string(“”) similarly, you’d have to compare with === to see the difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:01:36+00:00Added an answer on May 11, 2026 at 8:01 pm

    From google: http://bugs.mysql.com/bug.php?id=480

    [23 May 2003 4:32] Alexander Keremidarski

    Thank you for taking the time to write to us, but this is not
    a bug. Please double-check the documentation available at
    http://www.mysql.com/documentation/ and the instructions on
    how to report a bug at http://bugs.mysql.com/how-to-report.php

    This is doccumented behaviour of CONCAT() function.

    From Manual chapter 6.3.2 String Functions

    CONCAT(str1,str2,…)
    Returns the string that results from concatenating the arguments. Returns NULL if any
    argument is NULL

    Use CONCAT_WS() instead or wrap NULLable paremeters with IFNULL() function.

    Documentation and usage for CONCAT_WS: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_concat-ws

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 166k
  • Answers 166k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The Capture property is the correct way, but there are… May 12, 2026 at 1:21 pm
  • Editorial Team
    Editorial Team added an answer ConcurrentLinkedQueue or LinkedBlockingQueue are two options that immediately come to… May 12, 2026 at 1:21 pm
  • Editorial Team
    Editorial Team added an answer Depends on who you ask. It's OK according to W3,… May 12, 2026 at 1:21 pm

Related Questions

In the application I'm writing using a combination of development environments and languages, I
I have a completed web app in PHP 5 + MySQL. I have not
I am using MySQL 5.0 for a site that is hosted by GoDaddy (linux).
Is there a way to start a script from another process, so that if

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.