Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Answer: How do I get "table.column" format from a select/join?

by derobert (Initiate)
on Jan 27, 2009 at 21:43 UTC( #739361=categorized answer: print w/replies, xml ) Need Help??

Q&A > database programming > How do I get "table.column" format from a select/join? - Answer contributed by derobert

Do not use SELECT *. Not only are you probably pulling far more data than you need (which may or may not matter, depending on how big that data is) but as you've noticed, duplicate field names are problematic and make your code fragile (what happens when the DBA adds another column?). Instead, select exactly the columns you need, and under the names you want:
SELECT p.gene_id AS parent_gene_id, c.gene_id AS child_gene_id, c.name AS child_name FROM parent p LEFT JOIN child c ON ( p.gene_id = c.gene_id ) /* etc. */

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2016-08-30 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The best thing I ever won in a lottery was:















    Results (418 votes). Check out past polls.