Row_Rendered SELECT query custom field

I have a table containing a custom field
In another table’s Row_Rendered event I need to get a bunch of values from the first table.My custom field name is Lookup_KJhere’s the contents of my row rendered function:$GetClass = ExecuteScalar(“SELECT fk_Klass from Students where Isikukood =”.$this->fk_Student_ID->CurrentValue);
$GetStudent = ExecuteScalar(“SELECT V_Fullname from Students where Studentcode =”.$this->fk_Student_ID->CurrentValue);
$GetKJid = ExecuteScalar(“SELECT Lookup_KJ from Students where Studentcode =”.$this->fk_Student_ID->CurrentValue);
$GetKJname = ExecuteScalar(“SELECT V_Fullname from Personnel where ID =”.$GetKJid); $this->fk_Student_ID->ViewValue = $GetStudent." | “.$this->fk_Student_ID->CurrentValue.” | “.$GetClass.” | ".$GetKJname;the var $GetKJid is the one that returns nothing, all other vars are working.How can I get this working?

Custom field does not actually exist in the database, you cannot select it by SQL, you may replace “Lookup_KJ” in your SQL by the field expression of the custom field.

That’s kind what i assumed.
I’ll try your suggestion. thanks.

Lookup_KJ custom field SQL in the Students table looks like this:
(SELECT Klassid.fk_Klassijuht FROM Klassid WHERE Klassid.Klass = Students.fk_Klass)My new variable in Row_Rendered looks like this
$GetKJname = ExecuteScalar(“SELECT Klassid.fk_Klassijuht FROM Klassid WHERE Klassid.Klass =”.$GetClass);var dump of $GetKJname returns “bool(false)” for each row which i don’t understand at all. these are not boolean fields.

Got it working finally, I needed to add quotes around the $GetClass variable on second line :slight_smile:
For the benefit of others, here’s the final code:$GetClass = ExecuteScalar(“SELECT fk_Klass Students where Isikukood =”.$this->fk_Student_ID->CurrentValue); //find out what class the student is in
$GetKJid = ExecuteScalar(“SELECT Classes.fk_Klassijuht FROM Classes WHERE Classes.Klass ='”.$GetClass.“'”); //lookup the student’s class teacher ID - - since $GetClass returns a string not a number, it needs the extra quotes
$GetKJname = ExecuteScalar(“SELECT V_Fullname from Personnel where ID =”.$GetKJid); //lookup the teacher id nr from personnel table
$StudentOldValue = $this->fk_Student_ID->ViewValue; //put old view value into variable
$StudentNewValue = $this->fk_Student_ID->ViewValue." (“.$GetKJname.”)"; //append class teacher to old view value
$this->fk_Student_ID->ViewValue = $StudentNewValue; //new view valueVery certain there are more efficient ways to do this, but it works.