Loading ...
Sorry, an error occurred while loading the content.

RE: [SQLQueriesNoCode] Query help

Expand Messages
  • Katrina Illidge
    A nested sub-query something like this should do the trick. SELECT country_code FROM approval_country WHERE approval_id IN (Select approval_id FROM
    Message 1 of 7 , Mar 5, 2003
    • 0 Attachment
      A nested sub-query something like this should do the trick.

      SELECT country_code
      FROM approval_country
      WHERE approval_id IN
      (Select approval_id
      FROM approval_country
      Where approval_country.country_code = x)

      Hth

      katrina

      -----Original Message-----
      From: McMahon, Pat [mailto:pat.mcmahon@...]
      Sent: Thursday, 6 March 2003 8:32 AM
      To: SQLQueriesNoCode@yahoogroups.com
      Subject: [SQLQueriesNoCode] Query help

      I have three tables:

      approval:
      approval_id (int)
      created_date (date)

      country:
      country_code (int)
      country_desc (char)

      approval_country:
      approval_id
      country_code

      An approval has 1-many countries.

      What I need to do is find all the approvals
      for which at least one specific country_code
      exists, but I also need any other country_codes
      that may be associated with those approvals
      as well.

      Put another way, I need to find all approvals where at
      least one of the countries is say, Belgium. If there is a match,
      then I need all countries for that approval.

      Does this make sense?

      Thanks!

      P@

      "The early bird may get the worm, but the second mouse gets
      the cheese."



      To unsubscribe from this group, send an email to:
      SQLQueriesNoCode-unsubscribe@yahoogroups.com



      Your use of Yahoo! Groups is subject to
      http://docs.yahoo.com/info/terms/
    • McMahon, Pat
      Thank you Katrina and Kevin - that worked! ... From: Katrina Illidge [mailto:ki@keyit.net] Sent: Wednesday, March 05, 2003 9:19 PM To:
      Message 2 of 7 , Mar 6, 2003
      • 0 Attachment
        Thank you Katrina and Kevin - that worked!

        -----Original Message-----
        From: Katrina Illidge [mailto:ki@...]
        Sent: Wednesday, March 05, 2003 9:19 PM
        To: SQLQueriesNoCode@yahoogroups.com
        Subject: RE: [SQLQueriesNoCode] Query help




        A nested sub-query something like this should do the trick.

        SELECT country_code
        FROM approval_country
        WHERE approval_id IN
        (Select approval_id
        FROM approval_country
        Where approval_country.country_code = x)

        Hth

        katrina

        -----Original Message-----
        From: McMahon, Pat [mailto:pat.mcmahon@...]
        Sent: Thursday, 6 March 2003 8:32 AM
        To: SQLQueriesNoCode@yahoogroups.com
        Subject: [SQLQueriesNoCode] Query help

        I have three tables:

        approval:
        approval_id (int)
        created_date (date)

        country:
        country_code (int)
        country_desc (char)

        approval_country:
        approval_id
        country_code

        An approval has 1-many countries.

        What I need to do is find all the approvals
        for which at least one specific country_code
        exists, but I also need any other country_codes
        that may be associated with those approvals
        as well.

        Put another way, I need to find all approvals where at
        least one of the countries is say, Belgium. If there is a match,
        then I need all countries for that approval.

        Does this make sense?

        Thanks!

        P@

        "The early bird may get the worm, but the second mouse gets
        the cheese."



        To unsubscribe from this group, send an email to:
        SQLQueriesNoCode-unsubscribe@yahoogroups.com



        Your use of Yahoo! Groups is subject to
        http://docs.yahoo.com/info/terms/






        To unsubscribe from this group, send an email to:
        SQLQueriesNoCode-unsubscribe@yahoogroups.com



        Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      • Modha Kumar
        Hi All I have a table meta_table( int seq_id, varchar(50) tablename, varchar (50) columnname, int col_num) Data Like this: seq tablename columnname col_num
        Message 3 of 7 , Aug 23, 2006
        • 0 Attachment
          Hi All

          I have a table meta_table( int seq_id, varchar(50) tablename, varchar
          (50) columnname, int col_num)

          Data Like this:

          seq tablename columnname col_num
          =================================
          1 tab1 col4name 4
          2 tab2 xxx 3
          3 tab1 yyy 2
          4 tab2 ppp 5
          5 tab2 qqq 1

          Given a tablename how do I get colnumber and colname sorted by col_num.

          Please let me know.
          I am using SQL SERVER 2005.

          Thanks
        • Lester F. Callif
          Select mt.seq_id, mt.tablename, mt.columnname, mt.col_num From meta_table mt Order By mt.seq_id, mt.tablename, mt.columnname, mt.col_num The above SQL will
          Message 4 of 7 , Aug 24, 2006
          • 0 Attachment
            Select mt.seq_id, mt.tablename, mt.columnname, mt.col_num
            From meta_table mt
            Order By mt.seq_id, mt.tablename, mt.columnname, mt.col_num

            The above SQL will sort the rows by seq_id, followed by tablename, followed
            by coulmnname and finally followed by col_num.

            -----Original Message-----
            From: SQLQueriesNoCode@yahoogroups.com
            [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Modha Kumar
            Sent: Wednesday, August 23, 2006 9:10 PM
            To: SQLQueriesNoCode@yahoogroups.com
            Subject: [SQLQueriesNoCode] Query help

            Hi All

            I have a table meta_table( int seq_id, varchar(50) tablename, varchar
            (50) columnname, int col_num)

            Data Like this:

            seq tablename columnname col_num
            =================================
            1 tab1 col4name 4
            2 tab2 xxx 3
            3 tab1 yyy 2
            4 tab2 ppp 5
            5 tab2 qqq 1

            Given a tablename how do I get colnumber and colname sorted by col_num.

            Please let me know.
            I am using SQL SERVER 2005.

            Thanks











            Yahoo! Groups Links
          • Michael Weiss
            If you add in a WHERE clause you can limit the results to those rows that pertain to the specific table in question - DECLARE @myTable varchar(50) SET @myTable
            Message 5 of 7 , Aug 24, 2006
            • 0 Attachment
              If you add in a WHERE clause you can limit the results to those rows
              that pertain to the specific table in question -

              DECLARE @myTable varchar(50)
              SET @myTable = 'MyTableName'

              Select mt.seq_id, mt.tablename, mt.columnname, mt.col_num
              From meta_table mt
              WHERE mt.tablename = @myTable
              Order By mt.seq_id, mt.tablename, mt.columnname, mt.col_num

              Hth,
              Michael

              -----Original Message-----
              From: SQLQueriesNoCode@yahoogroups.com
              [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Lester F. Callif
              Sent: Thursday, August 24, 2006 7:45 AM
              To: SQLQueriesNoCode@yahoogroups.com
              Subject: RE: [SQLQueriesNoCode] Query help

              Select mt.seq_id, mt.tablename, mt.columnname, mt.col_num
              From meta_table mt
              Order By mt.seq_id, mt.tablename, mt.columnname, mt.col_num

              The above SQL will sort the rows by seq_id, followed by tablename,
              followed
              by coulmnname and finally followed by col_num.

              -----Original Message-----
              From: SQLQueriesNoCode@yahoogroups.com
              [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Modha Kumar
              Sent: Wednesday, August 23, 2006 9:10 PM
              To: SQLQueriesNoCode@yahoogroups.com
              Subject: [SQLQueriesNoCode] Query help

              Hi All

              I have a table meta_table( int seq_id, varchar(50) tablename, varchar
              (50) columnname, int col_num)

              Data Like this:

              seq tablename columnname col_num
              =================================
              1 tab1 col4name 4
              2 tab2 xxx 3
              3 tab1 yyy 2
              4 tab2 ppp 5
              5 tab2 qqq 1

              Given a tablename how do I get colnumber and colname sorted by col_num.

              Please let me know.
              I am using SQL SERVER 2005.

              Thanks











              Yahoo! Groups Links












              Yahoo! Groups Links
            Your message has been successfully submitted and would be delivered to recipients shortly.