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 174969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:37:00+00:00 2026-05-11T13:37:00+00:00

I am looking for an unobtrusive way to find and replace table names based

  • 0

I am looking for an unobtrusive way to find and replace table names based on their position in an SQL query.

Example:

$query = 'SELECT t1.id, t1.name, t2.country FROM users AS t1, country AS t2 INNER JOIN another_table AS t3 ON t3.user_id = t1.id'; 

I essentially need to prepend client name abbreviations to table names and then have my CMS handle that change. So, going from ‘users’ to ‘so_users’ (If Stack Overflow was a client) but not have to add curly braces around all query table names like Drupal. An example is how WordPress will allow you on setup to prepend table names, but the way WordPress handles this issue is not ideal for my means.

For my example I want the output of some method to be:

$query = 'SELECT t1.id, t1.name, t2.country FROM so_users AS t1, so_country AS t2 INNER JOIN so_another_table AS t3 ON t3.user_id = t1.id'; 

(‘so_’ in prepended to table names)

Thank you.

Kris

  • 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. 2026-05-11T13:37:01+00:00Added an answer on May 11, 2026 at 1:37 pm

    Using a query builder class would be the best solution, as you don’t want to make any assumption about the pattern you want to replace with regex. If you don’t find any existing library suitable for your particular need, roll out your own. It’s not hard to make a simple query builder.

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

Sidebar

Related Questions

Hi All I'm looking for a simple unobtrusive way to add a class=active to
I'm looking for a good 10 minute introduction to Unobtrusive Javascript using JQuery. I'm
Looking for an example that: Launches an EXE Waits for the EXE to finish.
I've never been able to find a good script or plugin for sql server
I've been looking for a generic way to deal with bidirectional associations and a
Looking for a open source mature ASP.NET based blog engine which supports themes. I
Looking at posts like this and others, it seems that the correct way to
Looking for an easy (preferably free) way to convert a few Mac PostScript Type
Looking for a simple query to truncate text by x amount of characters using
I'm looking for a way to add items to a spinner from within the

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.