Copy link to clipboard
Copied
Can anyone help me sort this out.
This code should spit out only the records that match a URK parameter $courscode but whatever I do it returns every record. I just can't figure out why?
$query_rs_dates = sprintf("SELECT * FROM dates09 UNION SELECT * FROM dates10 WHERE coursecode = '$coursecode' ORDER BY id", GetSQLValueString($colname_rs_dates, "text"));
$rs_dates = mysql_query($query_rs_dates, $con_tyf) or die(mysql_error());
$row_rs_dates = mysql_fetch_assoc($rs_dates);
$totalRows_rs_dates = mysql_num_rows($rs_dates);
Can anyone tell me where I am going wrong.
Cheers
Dave
Copy link to clipboard
Copied
Don't worry, I have fixed it.
Seems you have to have the WHERE bit first for each table. Like this:
SELECT * FROM dates09 WHERE coursecode = '$coursecode') UNION (SELECT * FROM dates10 WHERE coursecode = '$coursecode')
Sorry if I put anyone to any trouble. But maybe this will help someone with the same problem in the future
Cheers
Dave
Find more inspiration, events, and resources on the new Adobe Community
Explore Now