Friday, February 24, 2012

How to retrieve data from query and link the data to a data number?

i'm doing a project on SQL Server 2005, i'm stack in searching the data and can't link the data in the data number.. can someone help mi with the programming code? as i can search for the words in the table but i can't link with the data number..

am i doing the correct thing? this command will search for the keyword LIVER. or issit this command? i doing half way through..

SELECT Omim_No

FROM av

WHERE Description LIKE '%LIVER%'

ORDER BY Omim_No ASC

SELECT Omim_No

FROM cs

WHERE CS_Description LIKE '%LIVER%'

OR CS_DATA LIKE '%LIVER%'

ORDER BY Omim_No ASC

SELECT Omim_No

FROM ti

WHERE Omim_Titles LIKE '%LIVER%'

ORDER BY Omim_No ASC

SELECT Omim_No

FROM ti_alt_title

WHERE Omim_Alt_Titles LIKE '%LIVER%'

ORDER BY Omim_No ASC

SELECT Omim_No

FROM tx

WHERE Omim_Text LIKE '%LIVER%'

SELECT subsnp_id,pop_id,allele_id

FROM AlleleFreqBySsPop

WHERE source LIKE '%LIVER%'

SELECT aln_id

FROM b125_Alignments_35_1

WHERE tr_acc LIKE '%LIVER%'

OR ctg_name LIKE '%LIVER%'

OR ctg_acc LIKE '%LIVER%'

OR tr_orient LIKE '%LIVER%'

SELECT ctg_id,exon_number,exon_start,exon_end

FROM b125_ContigExon_1_1

WHERE mrna_acc LIKE '%LIVER%'

SELECT ctg_id,exon_number,exon_start,exon_end,seg_start,seg_end

FROM b125_ContigExon_35_1

WHERE mrna_acc LIKE '%LIVER%'

SELECT b125_ContigInfo_1_1.*

FROM b125_ContigInfo_1_1

WHERE contig_acc LIKE '%LIVER%'

OR contig_name LIKE '%LIVER%'

OR contig_chr LIKE '%LIVER%'

OR group_term LIKE '%LIVER%'

OR group_label LIKE '%LIVER%'

OR contig_label LIKE '%LIVER%'

SELECT b125_ContigInfo_34_3.*

FROM b125_ContigInfo_34_3

WHERE contig_acc LIKE '%LIVER%'

OR contig_name LIKE '%LIVER%'

OR contig_chr LIKE '%LIVER%'

OR group_term LIKE '%LIVER%'

OR group_label LIKE '%LIVER%'

OR contig_label LIKE '%LIVER%'

SELECT b125_ContigInfo_35_1.*

FROM b125_ContigInfo_35_1

WHERE contig_acc LIKE '%LIVER%'

OR contig_name LIKE '%LIVER%'

OR contig_chr LIKE '%LIVER%'

OR group_term LIKE '%LIVER%'

OR group_label LIKE '%LIVER%'

OR contig_label LIKE '%LIVER%'

SELECT b125_CrashedInfo.*

FROM b125_CrashedInfo

WHERE snp_type LIKE '%LIVER%'

SELECT b125_MapLink_35_1.*

FROM b125_MapLink_35_1

WHERE snp_type LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

SELECT b125_MapLinkInfo_35_1.*

FROM b125_MapLinkInfo_35_1

WHERE accession LIKE '%LIVER%'

SELECT b125_ModelInfo_35_1.*

FROM b125_ModelInfo_35_1

WHERE tr_acc LIKE '%LIVER%'

OR donor LIKE '%LIVER%'

OR acceptor LIKE '%LIVER%'

OR alignment LIKE '%LIVER%'

SELECT b125_ProjectedSNP_35_1.*

FROM b125_ProjectedSNP_35_1

WHERE snp_type LIKE '%LIVER%'

SELECT b125_ProteinInfo_34_3.*

FROM b125_ProteinInfo_34_3

WHERE ref_seq_status LIKE '%LIVER%'

OR rna_accs LIKE '%LIVER%'

OR prot_accs LIKE '%LIVER%'

OR nucl_accs LIKE '%LIVER%'

SELECT b125_ProteinInfo_35_1.*

FROM b125_ProteinInfo_35_1

WHERE ref_seq_status LIKE '%LIVER%'

OR rna_accs LIKE '%LIVER%'

OR prot_accs LIKE '%LIVER%'

OR nucl_accs LIKE '%LIVER%'

SELECT b125_SNPContigLoc_34_3.*

FROM b125_SNPContigLoc_34_3

WHERE snp_type LIKE '%LIVER%'

OR phys_pos LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

SELECT b125_SNPContigLoc_34_3_dup.*

FROM b125_SNPContigLoc_34_3_dup

WHERE snp_type LIKE '%LIVER%'

OR phys_pos LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

SELECT b125_SNPContigLoc_34_3_fix.*

FROM b125_SNPContigLoc_34_3_fix

WHERE snp_type LIKE '%LIVER%'

OR phys_pos LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

SELECT b125_SNPContigLoc_35_1.*

FROM b125_SNPContigLoc_35_1

WHERE snp_type LIKE '%LIVER%'

OR phys_pos LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

SELECT b125_SNPContigLoc_35_1_ss.*

FROM b125_SNPContigLoc_35_1_ss

WHERE snp_type LIKE '%LIVER%'

OR phys_pos LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

SELECT b125_SNPContigLoc_35_1_ss_fixed.*

FROM b125_SNPContigLoc_35_1_ss_fixed

WHERE snp_type LIKE '%LIVER%'

OR phys_pos LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

SELECT b125_SNPContigLocusId_1_1_temp.*

FROM b125_SNPContigLocusId_1_1_temp

WHERE contig_acc LIKE '%LIVER%'

OR locus_symbol LIKE '%LIVER%'

OR mrna_acc LIKE '%LIVER%'

OR protein_acc LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

OR residue LIKE '%LIVER%'

OR build_id LIKE '%LIVER%'

SELECT b125_SNPContigLocusId_34_3.*

FROM b125_SNPContigLocusId_34_3

WHERE contig_acc LIKE '%LIVER%'

OR locus_symbol LIKE '%LIVER%'

OR mrna_acc LIKE '%LIVER%'

OR mrna_ver LIKE '%LIVER%'

OR protein_acc LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

OR residue LIKE '%LIVER%'

OR build_id LIKE '%LIVER%'

SELECT b125_SNPContigLocusId_35_1.*

FROM b125_SNPContigLocusId_35_1

WHERE contig_acc LIKE '%LIVER%'

OR locus_symbol LIKE '%LIVER%'

OR mrna_acc LIKE '%LIVER%'

OR mrna_ver LIKE '%LIVER%'

OR protein_acc LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

OR residue LIKE '%LIVER%'

OR build_id LIKE '%LIVER%'

SELECT b125_SNPContigLocusId_35_1_old.*

FROM b125_SNPContigLocusId_35_1_old

WHERE contig_acc LIKE '%LIVER%'

OR locus_symbol LIKE '%LIVER%'

OR mrna_acc LIKE '%LIVER%'

OR mrna_ver LIKE '%LIVER%'

OR protein_acc LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

OR residue LIKE '%LIVER%'

OR build_id LIKE '%LIVER%'

SELECT b125_SNPMapInfo_34_3.*

FROM b125_SNPMapInfo_34_3

WHERE snp_type LIKE '%LIVER%'

OR assembly LIKE '%LIVER%'

SELECT b125_SNPMapInfo_34_3_fix.*

FROM b125_SNPMapInfo_34_3_fix

WHERE snp_type LIKE '%LIVER%'

OR md5 LIKE '%LIVER%'

OR assembly LIKE '%LIVER%'

SELECT b125_SNPMapInfo_35_1.*

FROM b125_SNPMapInfo_35_1

WHERE snp_type LIKE '%LIVER%'

OR md5 LIKE '%LIVER%'

OR assembly LIKE '%LIVER%'

SELECT b125_SNPMapInfo_35_1_ss.*

FROM b125_SNPMapInfo_35_1_ss

WHERE snp_type LIKE '%LIVER%'

OR md5 LIKE '%LIVER%'

OR assembly LIKE '%LIVER%'

SELECT b125_WithdrawCandidates.*

FROM b125_WithdrawCandidates

WHERE subsnp_id LIKE '%LIVER%'

SELECT Batch.*

FROM Batch

WHERE handle LIKE '%LIVER%'

OR loc_batch_id LIKE '%LIVER%'

OR loc_batch_id_upp LIKE '%LIVER%'

OR batch_type LIKE '%LIVER%'

OR moltype LIKE '%LIVER%'

OR synonym_type LIKE '%LIVER%'

OR linkout_url LIKE '%LIVER%'

SELECT BatchCita.*

FROM BatchCita

WHERE citation LIKE '%LIVER%'

SELECT BatchCommLine.*

FROM BatchCommLine

WHERE line LIKE '%LIVER%'

SELECT BatchCultivar.*

FROM BatchCultivar

WHERE line LIKE '%LIVER%'

SELECT BatchMeExLine.*

FROM BatchMeExLine

WHERE line LIKE '%LIVER%'

SELECT BatchPrivLine.*

FROM BatchPrivLine

WHERE line LIKE '%LIVER%'

SELECT BatchStrain.*

FROM BatchStrain

WHERE line LIKE '%LIVER%'

SELECT BatchValCode.*

FROM BatchValCode

WHERE batch_id LIKE '%LIVER%'

SELECT chk_SNPContigLoc_35_1.*

FROM chk_SNPContigLoc_35_1

WHERE snp_type LIKE '%LIVER%'

OR phys_pos LIKE '%LIVER%'

OR allele LIKE '%LIVER%'

SELECT chk_SNPMapInfo_35_1.*

FROM chk_SNPMapInfo_35_1

WHERE snp_type LIKE '%LIVER%'

OR md5 LIKE '%LIVER%'

OR assembly LIKE '%LIVER%'

SELECT Contact.*

FROM Contact

WHERE handle LIKE '%LIVER%'

OR name LIKE '%LIVER%'

|||

Please tell me this is not one command ? It's huge.

At it's core, what you're doing is right, using the LIKE keyword.

|||how to link a result to a number? i mean inside the table..|||

I don't understand. You're selecting from multiple tables. Don't those tables have ID columns ? Can't you use those ?

|||i wan to search for the word and it will display the Omim number and the Omim number will link to another identical number to display the description.. can u do it?|||

Nothing you're saying makes sense to me. You're selecting multiple tables ? why can't you just use the same ID, isn't that what you're saying you want ?

|||because some tables inside contain only numbers so i have to search for the keyword and display the result(omim number) and link this result number to a table contain numbers must be identical numbers. it is so hard that i can't really explain well sorry.. my tasks is hard..|||

I'm sorry, I do not understand the question. What do you want to do ?

|||

first thing is how to search the keywords from the tables

Second thing after u search the result ,how to link the result to a number related to the result?

|||

you use the LIKE keyword to find data inside strings. You return the ID with the string in the query.

|||can u show an example? i wan to search from the whole tables.. will the code be very long?|||

I can't show you an example because I don't know the table schema you're using. You want SQL, right ?

select id, name from tblSomething where name LIKE '%text%'

|||

SELECT av.*,cs.*,ti.*,ti_alt_title.*,tx.*,AlleleFreqBySsPop.*,OmimVarLocusIdSNP.*

FROM av,cs,ti,ti_alt_title,tx,AlleleFreqBySsPop,OmimVarLocusIdSNP

WHERE

av.Omim_No = cs.Omim_No

AND av.Omim_No = ti.Omim_No

AND av.Omim_No = ti_alt_title.Omim_No

AND av.Omim_No = tx.Omim_No

AND av.Omim_No = OmimVarLocusIdSNP.omim_id

AND (

Description LIKE '%LIVER%'

OR CS_Description LIKE '%LIVER%'

OR CS_DATA LIKE '%LIVER%'

OR Omim_Titles LIKE '%LIVER%'

OR Omim_Alt_Titles LIKE '%LIVER%'

OR Omim_Text LIKE '%LIVER%'

)

how?

|||

What's wrong with this ? It will return all the data you could hope for. Do you want to generate new IDs, unique to the query and not in the DB ?

No comments:

Post a Comment