MySQL查询:需要建议

时间:2010-03-19 15:47:41

标签: mysql

"SELECT id as Id from dbTable WHERE code = ? AND CURDATE() BETWEEN 
start_date AND end_date AND offerId IN ('12321', '12124')";
//Passing arguments for the query
$args = array_merge(array(51342),$offerid);

//Execute the prepared query
$statement->execute($args);

现在数组(51342)代表代码+值的组合,除了我的数据库有值,代码列,所以我想要一个看起来像逻辑的查询

"SELECT id as Id from dbTable WHERE code and value 
//(Note here I do not know the syntax, 
//what am looking at is (code+value = ?), please advise on query) = ? 
AND CURDATE() BETWEEN start_date AND end_date AND offerId IN ('12321', '12124')"

1 个答案:

答案 0 :(得分:0)

刚刚搜索到了一个:

"SELECT id as Id from dbTable WHERE concat(code, value) = ? 
AND CURDATE() BETWEEN start_date AND end_date AND offerId IN ('12321', '12124')"

不确定这会完美无缺!!!

谢谢!!!