Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Mysql Recordset help

Explorer ,
Jul 09, 2009 Jul 09, 2009

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

TOPICS
Server side applications
326
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 09, 2009 Jul 09, 2009
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines