我想删除我的sql中的记录,其中数组作为输入,带有两个where语句

时间:2016-07-31 20:29:59

标签: php sql-server

我想删除我的sql中的记录,其中数组作为输入,带有两个where语句。我找不到像这样的陈述......

"DELETE FROM perpetualinventory WHERE productID= ".implode(',',$productID)" && expiryDate=".implode(',',$expiryDate);

建议的答案

 "DELETE FROM perpetualinventory WHERE productID IN (".implode(',',$productID)") AND expiryDate IN (".implode(',',$expiryDate).")";
  

语法错误,意外'")AND expiryDate IN("'(T_CONSTANT_ENCAPSED_STRING)

2 个答案:

答案 0 :(得分:0)

即使不建议您可以这样做

"DELETE FROM perpetualinventory WHERE productID IN (".implode(',',$productID).") AND  expiryDate IN (".implode(',',$expiryDate).")";

答案 1 :(得分:0)

此代码应该有效:

export default class App extends Component {
   constructor() {
   super();
   this.onInputChange = this.onInputChange.bind(this);

   this.state = {
     rangeValue: 50
   }
 }

onInputChange(e) {
   this.setState({ rangeValue: e.target.value});
}

render() {
   var {rangeValue} = this.state;

  // this logs unbearably slow and I want to be able to pass this value 
  // to a child component as a prop as it updates
  console.log(rangeValue)

  return (
     <div className="map-controls">
        <input type="range" onChange={this.onInputChange}></input>
        <ExampleComponent rangeValue={this.state.rangeValue} />
     </div>

  );
 }
}

说明:

DELETE FROM perpetualinventory WHERE productID IN ('".implode($productID,"', '")."') AND expiryDate IN ('".implode($expiryDate,"', '")."')";