Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Posts
    6

    Unanswered: Repeat SQL query for a set of values

    I have a set of values on which I would like to execute a particular query. I would like to know how I can implement this directly in the DB [basic SQL query]. Perhaps for, while etc should be used.

    Thanks

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    It's hard to understand what you want
    Please read the thread 'Must Read Before Posting' and rephrase your question ...
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jan 2005
    Posts
    6
    I have a set of employee IDs : 2, 3, 4, 6, 8, 10.

    Now, for each of these employee IDs, I need to insert a record in a table employee_dep with the fields employeeId, DepId.

    Assuming the same DepId throughout, how do I execute this query?

  4. #4
    Join Date
    Oct 2004
    Location
    DELHI INDIA
    Posts
    338
    Hi,

    you can use the FOR loop for this purpose.
    Please refer the SQL reference document for the syntax of the query to find out more detail about the "FOR Loop".


    Thanks,
    Jayanta

  5. #5
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    I would do
    insert into employee_dep select empid,'Dept1' from employee
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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