0

I'm trying to read rows from a .mdb file (MS Access) on Linux (Ubuntu), I've installed php5-odbc, mootools etc... My code is:

$dbName = "/path/file.mdb";

$handle=odbc_connect ("DRIVER=MDBTools; DBQ=$dbName;", "", "");

if(!$handle) {
   print "<p>Uh-oh! Failure to connect to DSN: <br />";
   odbc_errormsg();
}
else {
   print "done";
   $resultset=odbc_exec ($handle, "SELECT DISTINCT(col) FROM tab");
   odbc_result_all($resultset, "border=2");
   odbc_close($handle);
}

if I change SQL clause to SELECT col FROM tab it works well... Instead with DISTINCT clause I have this error:

odbc_exec(): SQL error: [unixODBC]Couldn't parse SQL, SQL state 08001 in SQLExecDirect

I've tried with square brackets and without too but it's the same... Help!!

Arnab Nandy
  • 6,472
  • 5
  • 44
  • 50

1 Answers1

0

The correct syntax is:

SELECT DISTINCT col FROM tab
PhilS
  • 1,634
  • 14
  • 23
  • What is the error message? Please post the exact SQL you are using. – PhilS Apr 21 '15 at 11:12
  • Sql: SELECT DISTINCT X_TZART FROM particolarita, error: odbc_exec(): SQL error: [unixODBC]Couldn't parse SQL, SQL state 08001 in SQLExecDirect – Giuseppe Romano Apr 21 '15 at 11:15
  • Can you try this with another column, which has no underscore in it's name? - I vaguely rember there were issues with mdbtools and underscores, but I cannot recall details or a solution. – PhilS Apr 21 '15 at 11:30