[dba-SQLServer] Newbie needs help with select statement

jean-paul jnatola at hotmail.com
Sat Jan 31 18:34:15 CST 2009


there are also  sets of tables with the same name with a  _seq  attached to the name
i.e.
contacts_seq
contacts_organization_types_seq
 
          Jean-Paul Natola > From: ab-mi at post3.tele.dk> To: dba-sqlserver at databaseadvisors.com> Date: Sun, 1 Feb 2009 00:45:24 +0100> Subject: Re: [dba-SQLServer] Newbie needs help with select statement> > Jean-Paul,> > In that case I guess Francisco is right: you have a so called "many-to-many> relationship" comprising tree table: contacts -> "junctiontable" <-> contacts_organization_types.> What you need is find the name of this "junctiontable" in your database (I> know this is easier to say than to do...)> If you find a table in your databases which seems to be a link between your> contacts and contacts_organization_types table then please tell, and be sure> someone on this list will escort you the rest of the way.> > Asger> > -----Oprindelig meddelelse-----> Fra: dba-sqlserver-bounces at databaseadvisors.com> [mailto:dba-sqlserver-bounces at databaseadvisors.com] På vegne af jean-paul> Sendt: 1. februar 2009 00:11> Til: dba-sqlserver at databaseadvisors.com> Emne: Re: [dba-SQLServer] Newbie needs help with select statement> > > the contacts table does NOT have organization type- it has id, first, last,> add , cty, st, zip, tel, fax, dte_created, email, etc.. but nothing> regarding organization type- I will try you code and let you know- if been> on this for the last 30 hours racking my brain- on a good note i read and> learned alot since yesterday btw, I'm using MySQL and doing this via> phpMyAdmin- if it makes any difference Jean-Paul Natola > From:> ab-mi at post3.tele.dk> To: dba-sqlserver at databaseadvisors.com> Date: Sat, 31> Jan 2009 23:58:09 +0100> Subject: Re: [dba-SQLServer] Newbie needs help with> select statement> > Francisco may be is right about a third junction table> between your contacts> and contacts_organization_types tables. But perhaps> it's more simple that> that.> > You told us the tree fieldnames of your> contacts_organization_types table> (id, organization_type, and> internal_only) but you didn't tell us all names> of the 24 fields in your> contacts table.> > My question is: do your contacts table have a field named> something like> "organization_type_id"?> > In that case you might have a> simple one-to-many relationship and your query> would be something like:> >> SELECT ctcs.*, cot.organization_type FROM contacts AS ctcs> INNER JOIN> contacts_organization_types AS cot ON ctcs.organization_type_id> = cot.id> _________________________________________________________________> Windows Live™ Hotmail®…more than just e-mail. > http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_hm_justgotbetter_howi> tworks_012009> _______________________________________________> dba-SQLServer mailing list> dba-SQLServer at databaseadvisors.com> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver> http://www.databaseadvisors.com> > > > _______________________________________________> dba-SQLServer mailing list> dba-SQLServer at databaseadvisors.com> http://databaseadvisors.com/mailman/listinfo/dba-sqlserver> http://www.databaseadvisors.com> 
_________________________________________________________________
Windows Live™: E-mail. Chat. Share. Get more ways to connect. 
http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_012009


More information about the dba-SQLServer mailing list