Left join no MySQL: buscando dados exclusivos a uma tabela

Dadas as tabelas e seus campos:

  • genes: gene, active
  • copies: gene
  • same_as: gene

obter, os “gene” que estão presentes apenas na tabela genes e apresentam active=”Y”:

$ select genes.gene from genes left join same_as on (genes.gene=same_as.gene) left join copies on (genes.gene=copies.gene) where same_as.gene is null and copies.gene is null and genes.active=’Y’;

2 thoughts on “Left join no MySQL: buscando dados exclusivos a uma tabela

  1. What genuinely inspired u to create “Left join
    no MySQL: buscando dados exclusivos a uma tabela E-notações”?
    I reallytruly adored the blog post! Thanks for your time ,
    Mayra

    1. Hi, thanks for the kind comment.
      I was working on a project for which I needed to join those fields, literally. It took me a while to figure out how to do it, so when I succeeded, I decided to write the solution up for future reference.
      Basically, each gene can potentially have gene copies, so I wanted to retrieve that information.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s