Posted on 2012-08-15
Last Modified: 2012-08-16
I have a mysql table field FullPath

I want to show two fields in this field and am using
SELECT concat(boats.imagedirectory,' ',boats.image1_thumb) AS FullPath FROM boats to do this.
I cannot see an error but the field FullPath is empty.

Can anyone see my error please?

Many thanks
Question by:johnhardy
    LVL 49

    Accepted Solution

    That should work - what are your fields defined as for
    imagedirectory and image1_thumb
    Try this
    SELECT boats.imagedirectory, boats.image1_thumb, concat(boats.imagedirectory,' test') AS FullPath FROM boats

    Open in new window

    and this
    SELECT concat(boats.image1_thumb,' test') AS FullPath FROM boats

    Open in new window

    In both cases verify data is coming out as expected.
    LVL 21

    Expert Comment

    by:Kim Walker
    Check for upper case and lower case letters in the field names in your database. I've seen odd situations with case-sensitivity where the query returned an empty field without error when the field name was improperly capitalized.

    Author Closing Comment

    Thanks Julian

    I changed your suggested code a little and its now working OK

    LVL 31

    Expert Comment

    What does
    select concat_ws(' ',imagedirectory,image1_thumb) as full_path from boats result in?

    Author Comment

    Thanks awking00

    That gave the correct the correct result.

    I'm not sure of the difference of concat and concat_ws

    You realise the question is closed now but thanks anyway

    LVL 31

    Expert Comment

    The difference is that if any arguments using concat are null, it will return null, while concat_ws will skip any null arguments (although it will return null if the separator is null).

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
    Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
    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.

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now