the following SQL returns the data I need, but I don't know how to access it as I need with PHP. I can demo that the data can be used as I want as evidenced by output in a free PHP code generator by SQL Maestro, but it produces files dependent upon much more library code than I need.
I simply want to access the row values from two separate table alias columns, Name_value and Nmbr_value, as shown in the img.
Code: Select all
SELECT DISTINCT Nmbr.uid as Nmbr_uid, Nmbr.fid as Nmbr_fid, Nmbr.value as Nmbr_value, Name.fid as Name_fid, Name.value as Name_Value, u.uid as u_uid, u.status as u_status, Name.uid as Name_uid FROM profile_values Nmbr INNER JOIN users u ON u.uid = Nmbr.uid INNER JOIN profile_values Name ON Name.uid = u.uid WHERE Name.fid = 1 AND Nmbr.fid = 11 AND Nmbr.value != '' AND (Name.value!='Retiree' OR Nmbr.value = '1') ORDER BY Name.value DESC
I've heard this type of SQL query referred to as a "SELF JOIN". In any case, I don't know how to iterate over this type of result set so I can use it e.g. to create HTML forms, etc.