SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    belfast
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Copy rows to another table

    Hey everyone - need to copy specific rows/columns from one table to another existing table. How do I go about it?

    I need to use a session var as the id in the new table.

    Do I need to use an insert statement.

    Examples much appreciated.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    the syntax varies with the database

    your database might use --

    CREATE TABLE table2 SELECT * FROM table1 WHERE foo = 'bar'

    or perhaps it might use --

    SELECT * FROM table1 INTO table2 WHERE foo = 'bar'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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