If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Remove column prefixes in result

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-13-07, 10:27
Prodoc Prodoc is offline
Registered User
 
Join Date: Mar 2004
Posts: 13
Remove column prefixes in result

DB: MySQL 5

Is there a way to remove a prefix from each column name in a result, with a select statement, without having to specifically mention each column name? It might seem rather pointless but I'd like to use this in a joined table view where each table uses a different prefix, allowing me to update both tables without using the prefix.
I'd like to prevent having to specifically specify each column like 'bla_blaat AS blaat, bla_blabla AS blabla, etc.' since this can become a very long list which you'd have to update each time you change the original table(s).
Achieving the goal from the other side on UPDATE isn't possible or preferable either. The DB probably won't allow me to be non-specific about the column names and setting the values not including a column name forces me to maintain a very accurate order of specifying to values. Dropping the prefixes would be the easiest solution but this is something I'd like to prevent.

The following didn't work as expected: "SELECT * AS SUBSTRING(*, LOCATE('_', *) + 1) FROM user".

It seems you can do all sorts of tricks after the SELECT but non include using the * wild card.
Reply With Quote
  #2 (permalink)  
Old 09-13-07, 10:41
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Post moved to mySQL topic.
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 09-13-07, 11:07
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
there is only one way to solve your conundrum

back up your data, drop all your tables, redefine them without the prefixes, and reload your data

let me know when you've done that, because you may need to change some of your join queries

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On