Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 surveying the Monastery: (8)
As of 2015-07-07 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls