I have a sql statement that is a union of several queries.
"SELECT a, b, c, 'd' as type FROM x WHERE id = $id UNION ALL
SELECT a, b, c, 'e' as type FROM y WHERE id = $id UNION ALL
SELECT a, b, c, 'f' as type FROM z WHERE id = $id ORDER BY a DESC LIMIT 10";
I try to iterate through the results and get 'a' value for each row but can't make it to work.
for($i = 0 ; $i < mysql_num_rows($result) ; $i++){
$row = mysql_fetch_assoc($result);
echo($row['a']);
}
I know it is a silly question but I got stuck. Any ideas please? Thanks!