Results 1 to 6 of 6

Thread: sql query

  1. #1
    Join Date
    Sep 2004
    Posts
    16

    Unanswered: sql query

    I have a 250 tables and i want to query for every field that contains values >0 and not null. I then want to take those results and create a new table with 250 rows and two columns and populate it with the table name and populate the second with a Y if it is =0 or null and a N if it isn't. anyone have a idea how to do this recursively, without using the script for each indiv field?
    Last edited by bosewicht1; 09-02-04 at 23:45.

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Iteratively this would be relatively easy, recursively I can't think of any way to do it. Which database engine are you using (DB2, Microsoft, MySQL, Oracle, other)?

    -PatP

  3. #3
    Join Date
    Sep 2004
    Posts
    16
    using sql. i thought i started to get pretty close, and am working on it, but figured i would post while i worked on it

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Quote Originally Posted by Pat Phelan
    Which database engine are you using (DB2, Microsoft, MySQL, Oracle, other)?
    Quote Originally Posted by bosewicht1
    using sql.
    Whose SQL: (DB2, Microsoft, MySQL, Oracle, other)?

  5. #5
    Join Date
    Sep 2004
    Posts
    16
    using microsoft mdb's
    Last edited by bosewicht1; 09-03-04 at 16:18.

  6. #6
    Join Date
    Sep 2004
    Posts
    16
    ok, so here's where i am.

    INSERT INTO Table2 (FIELD1)
    SELECT *
    FROM TABLE1:

    which should insert all fields into the field FIELD1 in TABLE2 ???

    then i need to write a script that will loop through each field
    name and adds:

    INSERT INTO Table2 (FIELD2)
    ([Field Name] = 0) Or ([Field Name] IS NULL)
    to a string, and then run a query on
    "SELECT count(*) FROM Table1 WHERE " + [the constructed string]

    any ideas?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •