The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

SQL question

Hello, is there some way to transform all field names automatically?

Example:

select
  table1.f1,
  table1.f2 as table1_f2,
  table1.f3,
  table2.f2 as table2_f2
from table1, table2 where some_condition

But without *actually writing it*?

Like for example,

select table1.* as table_*, table2.* as table2_* from table1, table2

I'm using MySQL.

Thanks.
BladeFan0
Thursday, September 27, 2007
 
 
You could use the DBA trick to write a script to write the script you want. Works with anything, not just SQL.

(BTW, I call this the DBA trick, as it was a DBA who first introduced the technique to me, many years ago).
Entries of Confusion Send private email
Thursday, September 27, 2007
 
 
Well I'm doing this for generated SQL so the generator can generate it, I was just wondering if there was a way to keep it (the sql) cleaner.

Thanks.
BladeFan0
Thursday, September 27, 2007
 
 
In an hour or so I wrote a MySQL 5 stored procedure generator for creating all my table maintenance procedures (sp_[table]GET, sp_[table]UPD, sp_[table]DEL, sp_[table]SEL), by querying the INFORMATION_SCHEMA. Tables, columns, schema, you can write a script off that easy enough.
Jason T
Thursday, September 27, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz