Here is my query in PHP what I would like to Do IF RATE field IS NULL then Records may not be insert in my MYSQL table. My query doesn’t work here.it’s says check syntax near WHERE. IT’s works fine with out where.I have PHPMYADMIN.
$sql = "INSERT INTO `order`(`po_number`, `vendor_name`, `market`, `start_date`, `end_date`, `qty`, `rate`, `comment`, `media_type`, `sub_vendor`) VALUES ('$po_number1[$i]','$master_vendor1[$i]','$market1[$i]','$start_date1[$i]','$end_date1[$i]','$qty1[$i]','$rate1[$i]','$comment1[$i]','$media_type1[$i]','$sub_vendor1[$i]') WHERE `rate` IS NOT NULL";
Any help Will be appreciate.
Thank You.
You can’t have a
WHEREclause on anINSERT INTOquery like that. You will have to do any conditional logic prior to the executing the insert query. An insert query adds a new row, therefore by definition there would be no row to evaluate aWHEREclause against. Are you wanting anUPDATEquery?After completing the loop you can display any errors: