EXTREME Overclocking Forums
Home | Reviews | Forums | Downloads | $ EXTREME Deals $ | RealTime Pricing | Free Magazines | Gear | Folding Stats Newsletter | Contact Us


Go Back   EXTREME Overclocking Forums > Software Discussion > Programming, DBMS, HTML, Web Related
Register Forum Rules FAQ Search Today's Posts Mark Forums Read

Welcome Guest Visitor! Please Register, It's Free and Fun To Participate!
The EXTREME Overclocking Forums are a place for people to learn how to overclock and tweak their PC's components like the CPU, memory (RAM), or video card in order to gain the maximum performance out of their system. There are lots of discussions about new processors, graphics cards, cooling products, power supplies, cases, and so much more!

You are currently viewing our boards as a "guest" which gives you limited access to view most discussions. You need to register before you can post: click the register link to proceed. Before you register, please read the forum rules. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own pictures, and access many other special features. Registration is fast, simple, and absolutely free! To start viewing messages, select the forum that you want to visit from the selection below.

After you have registered and read the forum rules, you can check out the FAQ for more information on using the forum. We hope you enjoy your stay here!

Note To Spammers: We do not allow unsolicited advertising! Spam is usually reported & deleted within minutes of it being posted, so don't waste your time (or ours)!


Please Register to Post a Reply
 
Thread Tools
Old 08-17-2012, 11:16 AM   #1
zlander79
Waldeinsamkeit
zlander79's Avatar
Senior Member
 
Posts: 745
Last Seen: 12-21-2012
iTrader: 0 / 0%
SQL Question

I updated a view, the only thing I changed was I added this statement:
Code:
		`os`.`site_distance` AS `Distance`,
I didn't change the join statements, where statements or anything. I'm getting different numbers of rows returned between the view with the added statement and without. Any idea why this is happening?
United States  Offline
    Register to Reply to This Post
Old 08-17-2012, 11:31 AM   #2
OS-Wiz
Old School
OS-Wiz's Avatar
Senior Member
 
Posts: 1,897
Last Seen: Yesterday
From: St. Louis MO USA
iTrader: 5 / 100%
Hmmm, need version of SQL (like Oracle, MySQL, whatever) and the complete statement. My first guess puntuation error. Or the ending comma changed the query but passed parsing/syntax checking.
United States  Offline
    Register to Reply to This Post
Old 08-17-2012, 03:55 PM   #3
zlander79
Waldeinsamkeit
zlander79's Avatar
Senior Member
 
Posts: 745
Last Seen: 12-21-2012
iTrader: 0 / 0%
view with the statement in it:
Code:
CREATE 
    ALGORITHM = UNDEFINED 
    DEFINER = `rpokeefe`@`%` 
    SQL SECURITY DEFINER
VIEW `METAGENO`.`COMP_REPORT_2` AS
    select 
        `g`.`id` AS `MH_gene_id`,
        `g`.`Name` AS `MH_name`,
        `f`.`Path` AS `MH_file`,
        `sc`.`Name` AS `MH_scaffold`,
        `g`.`Operon` AS `Operon`,
        `o`.`prime_gene` AS `Operon_Prime_Gene`,
        `os`.`site` AS `Site`,
        `os`.`site_type` AS `Site_Type`,
		`os`.`site_distance` AS `Site_Distance`,	
        `s`.`Score` AS `Site_Score`,
        `m`.`name` AS `Motif`,
        `gort`.`ortho` AS `ORTHO_NCBI_gi`,
        `gort`.`eval_coef` AS `GENE_ORTHO_E_coef`,
        `gort`.`eval_power` AS `GENE_ORTHO_E_power`,
        `rgi`.`gi` AS `COG_NCBI_gi`,
        `ortcp`.`eval_coef` AS `ORTHO_COG_E_coef`,
        `ortcp`.`eval_power` AS `ORTHO_COG_E_power`,
        `rgi`.`accession` AS `NCBI_Accession`,
        `rgi`.`description` AS `NCBI_Description`,
        `rgi`.`product` AS `NCBI_Product`,
        `cpc`.`cog` AS `COG`,
        `c`.`Name` AS `COG_Description`,
        `cpc`.`cogprot` AS `COG_Protein`,
        `cpc`.`cog_org` AS `COG_Protein_organism`,
        `cfg`.`id` AS `COG_Group`,
        `cfg`.`Desc` AS `COG_Group_Description`,
        `co`.`taxid` AS `Tax_id`,
        `co`.`name` AS `Organism_Name`,
        `s`.`Sequence` AS `Site_Sequence`
    from
        (((((((((((((((`METAGENO`.`GENE` `g`
        join `METAGENO`.`FILE` `f`)
        join `METAGENO`.`SCAFFOLD` `sc`)
        join `METAGENO`.`OPERON` `o`)
        join `METAGENO`.`OPERON_SITE` `os`)
        join `METAGENO`.`SITE` `s`)
        join `METAGENO`.`MOTIF` `m`)
        join `METAGENO`.`GENE_ORTHO` `gort`)
        join `METAGENO`.`ORTHO` `ort`)
        join `METAGENO`.`ORTHO_COGPROT` `ortcp`)
        join `METAGENO`.`COGPROT_COG` `cpc`)
        join `METAGENO`.`COG` `c`)
        join `METAGENO`.`COG_GROUP` `cg`)
        join `METAGENO`.`COG_FUNCTIONAL_GROUP` `cfg`)
        join `METAGENO`.`REF_GENE_INFO` `rgi`)
        join `METAGENO`.`COG_ORG` `co`)
    where
        ((`g`.`Operon` = `o`.`id`)
            and (`o`.`File` = `f`.`id`)
            and (`o`.`Scaffold` = `sc`.`id`)
            and (`o`.`id` = `os`.`operon`)
            and (`os`.`site` = `s`.`id`)
            and (`s`.`Motif` = `m`.`id`)
            and (`g`.`id` = `gort`.`gene`)
            and (`gort`.`ortho` = `ort`.`ortho`)
            and (`ort`.`ortho` = `ortcp`.`ortho`)
            and (`ortcp`.`cogprot` = `cpc`.`gi`)
            and (`cpc`.`gi` = `rgi`.`gi`)
            and (`cpc`.`cog` = `c`.`id`)
            and (`cpc`.`cog` = `c`.`id`)
            and (`c`.`id` = `cg`.`COG`)
            and (`cg`.`GROUP` = `cfg`.`id`)
            and (`cpc`.`cog_org` = `co`.`cog_org`))
    group by `gort`.`ortho`
    having max(`os`.`site`)
SQL query on view:
Code:
select * from METAGENO.COMP_REPORT_2 where  (Motif = "Gamma")
I'm using mysql

Additional Comment:

The only addition is the statement I had in the first post, everything else is the same. I really don't understand why this would change. It is sort of worrying me because I thought I had a fairly firm grasp on how this view was working

Rows returned without statement: 2700
Rows returned with statement : 2691

It might seem like a small amount but this isn't exactly data where we can fudge things.

Additional Comment:

I've checked through all of the data returned be each version of the view with the above SQL query. The vast majority of results were the same however each version brought back data that the other one did not.

I've pulled up everything on those entries and the "Site_Distance" value for the different entries isn't null or anything.

I'm really lost on this.

Additional Comment:

Even weirder, I changed the group by statement

from
Code:
group by `gort`.`ortho`
to
Code:
`g`.`id`
And now the query on the view brings back the same data regardless of which version of the view I used. Oh well, I've technically solved the issue but it still is a bit strange why that would happen.

Last edited by zlander79 : 08-17-2012 at 03:55 PM. Reason: Automerged Doublepost
United States  Offline
    Register to Reply to This Post
Old 08-17-2012, 10:06 PM   #4
OS-Wiz
Old School
OS-Wiz's Avatar
Senior Member
 
Posts: 1,897
Last Seen: Yesterday
From: St. Louis MO USA
iTrader: 5 / 100%
Hmmm, does column name 'Motif' exist in any of the other tables in the query?
The two different GROUP BY clauses might return (probably would return) a different number of rows.
I see no reason why simply adding another column to the select clause would change the number of rows returned (in Oracle and DB2 it would NOT). You sure the two different views executed against the same schema on the same host?
United States  Offline
    Register to Reply to This Post
Sponsored Links:
Please Register to Post a Reply


Thread Tools

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

All times are GMT -6. The time now is 12:52 AM.

Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Powered by vBulletin
Copyright ©2000 - 2011, EXTREME Overclocking