Home > front end >  How can I add a field outside a SELECT INTO statement into new table?
How can I add a field outside a SELECT INTO statement into new table?

Time:10-13

Given the statement

$SQL = "INSERT INTO members (lname, fname, vid, hphone, cphone, email, village ) 
           SELECT fname, lname, vid, hphone, cphone, email, village 
           FROM waitlist WHERE waitlist.vid = :vid";

Which works just fine; however, I also need to add a date into the expiration field of then members table. The expiration date is calculated before the above statement.

Thanks

CodePudding user response:

Add it as a literal value in the SELECT list.

$SQL = "INSERT INTO members (lname, fname, vid, hphone, cphone, email, village, expiration_date ) 
        SELECT fname, lname, vid, hphone, cphone, email, village, :expiration_date
        FROM waitlist WHERE waitlist.vid = :vid";
  • Related