I have a situation where I am using a UNION such as this:
$query = "SELECT bigimage, heading, fullarticle, dateadded FROM news ";
$query .= "WHERE (state = '" . $USER->state . "' OR state = 'ALL') AND status = 1 AND newstype != 1 AND frontpage = 1 AND bigimage > '' ";
$query .= "UNION ";
$query .= "SELECT image, eventname, details, dateadded FROM events ";
$query .= "WHERE (state = '" . $USER->state . "' OR state = 'ALL') AND status = 1 AND frontpage = 1 AND image > '' ";
$query .= "ORDER BY dateadded DESC LIMIT 10";
$restresult = mysql_query($query);
Now, what I am wanting to find out is which table each result comes from, so I was wondering if I could add some kind of custom result to each result returned to give me some form of indication what table it came from.
Could I add an extra “dynamic” column somehow in the returned result?
Try this: