Results 1 to 3 of 3

Thread: Using 'SELECT' statement and multiple filters?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2000
    Posts
    70

    Cool


    Hi,

    I have a table with project costs and each cost (record) has a resource code. I want to pull out all costs, where the resource code matches any one of eight resource codes specified. Then move those matching records to a different table.

    ie

    SELECT * from tbl WHERE RCode = "CHR" or "TRD" or ....(X8 Resource Codes)

    Then do the same for records using another set of resource codes and transfer these to a different table again.

    What is the best way, or any way, of doing this. Any code example would be appreciated.I am using VB6 and ADO.

    Cheers

  2. #2
    Lively Member
    Join Date
    Jul 2000
    Location
    Australia
    Posts
    69
    One way I thought would be to use a make table select statement using the in clause... rcode in ("RFT", "TRN",)
    and just use the execute statement to action the query in ADO.

    Gerard
    Live long and prosper...

  3. #3
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196

    Lightbulb

    Here's the thought.


    Do your target tables already exist? Are you using SQL Server or MS Access.

    Anyway,

    SQL Server:

    IF your target table does not exist yet, you could SQL Server could make it automatically for you. You just have to check the SELECT INTO/BULK Copy in the dp options. Right click on the database and then properties...or, if you want the hard way, use the sp_dboptions system stored procedure.

    Insert into <TARGET TABLE> Select column1, column2, columnn from tbl WHERE RCode IN ("CHR", "TRD",....X8 Resource Codes)

Posting Permissions

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



Click Here to Expand Forum to Full Width