Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

( #41086=categorized answer: print w/ replies, xml ) Need Help??

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

Lordy, don't change the column names. You can alias the name with AS in most SQL dialects:
SELECT p.gene_id, s.gene_id AS SecGene, ...

If the gene_id in the second table is a foreign key into the primary table, you really want it to have the same name, for your and everyone elses sanity. I gotta ask, is the gene_id field the field that you use to tie the two tables together? If so, and you have:

... FROM primary LEFT JOIN secondary ON primary.gene_id=secondary.gene +_id ...
in your select, then you really shouldn't ask for anything but the primary.gene_id from the left side of the join.

Comment on Answer: How do I get "table.column" format from a select/join?
Select or Download Code
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 romping around the Monastery: (12)
As of 2014-12-18 21:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (66 votes), past polls