Bluehost.com Web Hosting $6.95

Link Lookup on Two Tables

This is a discussion on Link Lookup on Two Tables within the MySQL Database forums, part of the Database Forums category; Dear expert, Suppose I have the following two tables: --- TABLE_A ---- +------------------------------------------------------------------ + GO_Term | GO_Id | Gene ID +--------------------------------------------------------------------- biological_process GO:0008150 814629 biological_process GO:...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-22-2007
ewijaya
 
Posts: n/a
Default Link Lookup on Two Tables

Dear expert,

Suppose I have the following two tables:

--- TABLE_A ----
+------------------------------------------------------------------
+ GO_Term | GO_Id | Gene ID
+---------------------------------------------------------------------
biological_process GO:0008150 814629
biological_process GO:0008150 814631
molecular_function GO:0003674 814631
.............................etc ..........................
+----------------------------------------------------------------

--- TABLE_B ----
+------------------------------------------------------------------
+ Gene_Symbol | Gene ID
+---------------------------------------------------------------------
AT2G01050 814629
AT2G01031 814631
PF14_0640 812222
..............................etc ..........................
+----------------------------------------------------------------

How can one construct a sql command so that:
1. Given GO_Term or GO_Id as Input
2. Obtain their respective Gene_Id
3. For each their Gene_Id finally return their Gene_Symbol.

Note that in Table A, the same GO_Term/GO_Id may contain
different Gene_ID.

Thanks and hope to hear from you again.

--
Regards,
Edward

Reply With Quote
  #2 (permalink)  
Old 04-22-2007
J.O. Aho
 
Posts: n/a
Default Re: Link Lookup on Two Tables

ewijaya wrote:
> --- TABLE_A ----
> +------------------------------------------------------------------
> + GO_Term | GO_Id | Gene ID
> +---------------------------------------------------------------------
> --- TABLE_B ----
> +------------------------------------------------------------------
> + Gene_Symbol | Gene ID
> +---------------------------------------------------------------------
> How can one construct a sql command so that:
> 1. Given GO_Term or GO_Id as Input
> 2. Obtain their respective Gene_Id
> 3. For each their Gene_Id finally return their Gene_Symbol.


Search for a GO_Term:
SELECT * FROM TABLE_B RIGHT JOIN TABLE_A ON(TABLE_B.`Gene ID`= TABLE_A.`Gene
ID`) WHERE GO_Term='something';

Search for a GO_Id:
SELECT * FROM TABLE_B INNER JOIN TABLE_A ON(TABLE_B.`Gene ID`= TABLE_A.`Gene
ID`) WHERE GO_Id='something';

Search in both GO_Term and GO_Id at the same time:
SELECT * FROM TABLE_B INNER JOIN TABLE_A ON(TABLE_B.`Gene ID`= TABLE_A.`Gene
ID`) WHERE GO_Term='something' OR GO_Id='something';

--

//Aho
Reply With Quote
  #3 (permalink)  
Old 04-23-2007
ewijaya
 
Posts: n/a
Default Re: Link Lookup on Two Tables

Hi Aho,

Thanks so much for your reply.
Is there a way I can optimize your querry above using Index?
Especially because the table I have are very large.


--
Regards,
Edward WIJAYA



On Apr 22, 9:52 pm, "J.O. Aho" <u...@example.net> wrote:

>
> Search for a GO_Term:
> SELECT * FROM TABLE_B RIGHT JOIN TABLE_A ON(TABLE_B.`Gene ID`= TABLE_A.`Gene
> ID`) WHERE GO_Term='something';
>
> Search for a GO_Id:
> SELECT * FROM TABLE_B INNER JOIN TABLE_A ON(TABLE_B.`Gene ID`= TABLE_A.`Gene
> ID`) WHERE GO_Id='something';
>
> Search in both GO_Term and GO_Id at the same time:
> SELECT * FROM TABLE_B INNER JOIN TABLE_A ON(TABLE_B.`Gene ID`= TABLE_A.`Gene
> ID`) WHERE GO_Term='something' OR GO_Id='something';
>
> --
>
> //Aho



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:41 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0