Problem with syntax and filling array
Hello, I've some experience with SQL but struggle now in Ninox
select Customers.Namen.Voornaam where Voornaam ="Ellen" result in "End expected: where at line 1, column 37
I tried also
(select Customers).Namen.Voornaam like Customers.Namen.Id = 4; Result is 'No' ??
(select Customers).Namen.Voornaam Where Customers.Namen.Id = 4; Result "End expected: where at line 2, column 39
I tried this code from support site
let refArray := [ID1, ID3, ID8, ID13];
let arrCount := count(refArray);
for i in range(0, arrCount) do
let myItems := (select MainTable where Reference = item(refArray, i));
let itemsCount := count(myItems);
for j in range(0, itemsCount) do
let newRec := (create TempTable);
newRec.(Field1 := item(myItems, j).Field1);
newRec.(Field2 := item(myItems, j).Field2)
end
end;
openTable("TempTable")
I altered it into my situation
let refArray := concat(customers.Namen.Id);
let arrCount := count(refArray);
for i in range(0, arrCount) do
let myItems := (select Namen where Id = item(refArray, i));
let itemsCount := count(myItems);
for j in range(0, itemsCount) do
let newRec := (create TempTable); Result:Table not found
newRec.(Field1 := item(myItems, j).Field1);
newRec.(Field2 := item(myItems, j).Field2)
end
end;
openTable("TempTable")
Also tried
let refArray := concat(Customers.Namen.Id);
let arrCount := count(refArray);
let fld := "";
for i in range(0, arrCount) do
let myItems := (select Namen where Id = item(refArray, i));
let itemsCount := count(myItems);
for j in range(0, arrCount) do
fld := fld + item(myItems, j);
fld := fld + item(myItems, j)
end
end;
fld
Also no result.
arrCount = always 1
refArray = "646, 654, 655, 656"
Who can explain this en give the right syntax.
3 replies
-
Hoi Wieland,
Try this:
select Customers where Voornaam like "Ellen"
or if Namen is a subtable of customers'
select Customers where Namen.Voornaam like "Ellen"
Steven
-
You are very close to getting Ninox. You wrote:
(select Customers).Namen.Voornaam like Customers.Namen.Id = 4
It could be written:
(select Customers where Namen.Id = 4).Namen.Voornaam <- I dropped the like as you had a equal sign
You have to put the search requirements at the level you want to search in.
Now the question is if you want data from field Voornaam and it seems to only be in the table Namen then why are you starting your select statement at Customers? Since you are using a select statement you can start at Namen. So it would look like:
(select Namen where Id = 4).Voornaam
Just be aware that if you switched to "like" you have to tell Ninox how you want to handle multiple results (even if there are not actual multiple results). You will then need to put the select statement in a first/last/sum/concat/etc function.
(select Namen where Id like 4).Voornaam
will return a blank field if you don't put it in:
concat((select Namen where Id like 4).Voornaam)
I hope this helps. I'll write more about troubleshooting techniques for your array.
-
Re-reading your post it looks like Customers is a reference field in whatever table you are in. Which means you don't need to do a select statement to get data from the Voornaam field if you want to find all Voornaam linked to the record you are looking at. You can put the following in a formula field and get the same results:
concat(Customers.Namen.Voornaam)
Using the power of Ninox you will find only records in the Namen table that is linked to the Customers table that are linked to the record in the current table you are in. And since there could be multiple records you have to tell Ninox how you want it to show your data. I'm guessing Voornaam is text so your only real option is concat.
Which brings me to your question about the array.
You wrote:
let refArray := concat(Customers.Namen.Id);
let arrCount := count(refArray);arrCount = always 1
refArray = "646, 654, 655, 656"
In Ninox the use of concat turns an array into a string. Which means Ninox can not do any of the nice array functions like count. Change the first line to:
let refArray := Customers.Namen.Id;
Then you will see arrCount return a proper number.
Good luck and let us know how it goes.
Content aside
- 3 yrs agoLast active
- 3Replies
- 248Views