I have two tables. When A user clicks a button, it will copy data from table 1 to table 2 where the doesn't already exist in table 2.
I had the query working just fine, until I added a new column in the first table named "onsite" - which is either set to yes, or it is NULL.
Here is the query I've tried. It no longer inserts ANY data to the past_bidder table (table 2)
- $copybidderquery = "INSERT INTO past_bidders(bidnum, bidfname, bidlname, bidphnum, bidlicense, bidaddress, bidtaxexempt, bidtaxid, date_created)
- SELECT bidnum, bidfname, bidlname, bidphnum, bidlicense, bidaddress, bidtaxexempt, bidtaxid, date_created
- FROM bidders
- WHERE (bidfname, bidlname, bidphnum, bidlicense, bidaddress)
- NOT IN (SELECT bidfname, bidlname, bidphnum, bidlicense, bidaddress FROM past_bidders)
- AND onsite != 'yes'";
I've also tried moving the where onsite != 'yes' to right after "WHERE" and it still does the same thing.
- $copybidderquery = "INSERT INTO past_bidders(bidnum, bidfname, bidlname, bidphnum, bidlicense, bidaddress, bidtaxexempt, bidtaxid, date_created)
- SELECT bidnum, bidfname, bidlname, bidphnum, bidlicense, bidaddress, bidtaxexempt, bidtaxid, date_created
- FROM bidders
- WHERE onsite != 'yes'
- AND (bidfname, bidlname, bidphnum, bidlicense, bidaddress)
- NOT IN (SELECT bidfname, bidlname, bidphnum, bidlicense, bidaddress FROM past_bidders)";
As stated, this query works just fine without the "onsite != 'yes'" line.
I think it's just some little syntax error I'm overlooking. Any help would be appreciated.