php - when using max() with mysqli, only one field is changing -
i having problems code:
$query="insert tripmembers(tripid,id) select max(tripid),'id' tripdetails"; $result=mysqli_query($conn,$query);
wherein tripid getting added,but id field not.(tried both or without single quotes around 'id')
my aim copy tripid , id "tripdetails' 'tripmembers' last entry of 'tripmembers' code not working:
$query="insert tripmembers(tripid,id) select tripid,id tripdetails tripid=max(tripid)";
iv checked spellings of fields yet id being stored 0 every time in "tripmembers" table ,but has proper id in "tripdetails" table
pease help!
the single quotes ('id'
) makes string literal. if that's being inserted id
column numeric datatype, literal string evaluate zero. if had specified literal zero.
if intent reference column named id
tripdetails table, remove single quotes. if that, value returned id column indeterminate. value row, row, in tripdetails table.
i suspect may want group id
clause, that's guess. it's not clear trying achieve.
Comments
Post a Comment