Answer the question
In order to leave comments, you need to log in
MySQL SELECT statement - how to set range of values in shorthand format?
View request:
SELECT type_1, type_2, type_3, type_4, type_5, type_6, type_7, type_8, type_9, type_10, type_11, type_12, type_13, type_14, type_15 FROM ".DB_TABLE." WHERE id1='".$id1[$c]."'
SELECT SOME_FUNCTION (type_1, type_15) FROM ".DB_TABLE." WHERE id1='".$id1[$c]."'
Answer the question
In order to leave comments, you need to log in
This will not work, but you are building a query like that, since at the end there is:
Take advantage of the opportunities provided by the tool with which you build the query. As far as I understand it is PHP.
For example like this:
$select = "";
for($i = 1; $i < 16; $i++){
$select .= "type_" . $i;
if($i < 15){
$select .= ", ";
}
}
Evgeny Kolegov, well, if it's in php, it's better like this)
class RikkiSQL {
public function RikkiValues($name, $num) {
$values = "";
for($i = 1; $i < $num; $i++) {
$values .= $name.$i.", ";
}
$values .= $name.$num;
return $values;
}
}
require_once CLASSES."RikkiSQL.class.php";
$sql = new RikkiSQL();
$cost_res2 = db1query("SELECT ".$sql->RikkiValues(building_type_, 15).", ".$sql->RikkiValues(building_cost_, 15).", ".$sql->RikkiValues(building_stotal_, 15).", ".$sql->RikkiValues(building_sliving_, 15).", ".$sql->RikkiValues(building_skit_, 15)." FROM ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question