I'm not sure that I understand what you are trying to doSo why do you want to get the highest number or the whole Thing re-numbered? What is it good for?
this works fine in mysql (prolly not in mssql)
B4X:INSERT INTO test ('name','position') select 'ilan',max(position)+1 from test
it's the subsequent querying I was talking about in post 11.
case "HighestId":
$q = mysql_query("SELECT id FROM $table");
$rows = array();
while($r = mysql_fetch_assoc($q))
{
$rows[] = $r;
}
print json_encode($rows);
break;
Dim maxid As String = "0"
If getstring.Contains(",") Then
Dim str() As String = Regex.Split(",",getstring)
Dim highestidlist As List
highestidlist.Initialize
For i = 0 To str.Length - 1
Dim str2() As String = Regex.Split(":",str(i))
highestidlist.Add(str2(1))
Next
For i = 0 To highestidlist.Size - 1
maxid = Max(maxid, highestidlist.Get(i))
Next
End If
maxid = maxid + 1
look at my previous post.
altho the primary key (auto increment tag in mysql) will always increase and won't have duplicates.
max position is not ok because i could have only 4 entries with the highest id of 8 because i have delete few entries so i need to check for the highest id and then add 1 to it
Ok, i thought you mean with max position just to count how much entries i have and then use it as my next id... sorry
case "HighestId":
mysql_query("INSERT INTO b4ausers ('name','position') select '$name',max(position)+1 from b4ausers");
break;
case "HighestId":
mysql_query("INSERT INTO b4ausers ('name') values ('$name')");
break;
Varchar can up to 256 bytes i think.varchar
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?