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

  • SEARCH
  • Home
  • 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 8716905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:11:37+00:00 2026-06-13T06:11:37+00:00

I have a table activity_types which contains the text for activities e.g. New project

  • 0

I have a table activity_types which contains the text for activities e.g.
New project has been assigned to {user} with name {project}
New discussion has been posted by {client} on {project}
Project {project} has been closed by {user}
A draft has been approved by {client} on {project}
and so on

I have another table in which the id of these texts has been populated.

Now my requirement is to fetch these by replacing the text within {} with their actual values like {client} should be replaced with client name, {project} should be replaced with project name.

I have tried using nested replace mysql function but it returns null string. Here is my query

SELECT      REPLACE(REPLACE(REPLACE(att.type_text, '{project}', p.project_business_name), '{user}', u.user_fullname), '{client}', c.client_name) AS activity, a.*
FROM        activities a
LEFT JOIN   activity_types AS att ON att.type_id = a.activity_type
LEFT JOIN   users u ON u.user_id = a.activity_user AND a.activity_user IS NOT NULL
LEFT JOIN   projects p ON p.project_id = a.activity_project AND p.project_is_removed = '0'
LEFT JOIN   clients c ON c.client_id = a.activity_client AND a.activity_client IS NOT NULL;

The problem is that if i replace the c.client_name with static text it works fine but when i replace the static string with c.client_name it return null in activities which does not have {client}. Any guesses where am i doing wrong?

  • 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-06-13T06:11:38+00:00Added an answer on June 13, 2026 at 6:11 am

    try adding COALESCE on the column

    ...,COALESCE(c.client_name, ''),
    

    basically if the column (c.client_name) is null, it will be replace with empty string.

    what happens is that when part of the string is replace with null, the whole string becomes null.

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

Sidebar

Related Questions

We have a (currently InnoDB) table which contains roughly 500,000 rows. This represents a
I have the following model: activity_types: id, name activities: id, id_activity_type, occurrences, date (other
Q: I have a gridview which contains text box as a template field.The grid
I have table in which I am inserting rows for employee but next time
I have decided to create a new table in my database that will be
I have a rather mundane Oracle table with seven rows. Each row has different
I have a table activities of activity entries, e.g.: ID | Date | Activity
I have a table that logs activity. It has an int activity column that
I have an activity table with a structure like this: id prd_id act_dt grp
I have an application that records activity in a table (Oracle 10g). The logging

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.