[Web4lib] ODBC query in PHP

Mark Sandford sandfordm1 at wpunj.edu
Thu Dec 14 14:38:05 EST 2006


Hi all,

I'm having some trouble getting SQL SELECT queries to work in PHP
using any type of JOIN.  I'm using odbc to talk to the Oracle DB
(we're a Voyager library).

The SQL statement works fine in MS Access, but not in the PHP page.
When I create SELECTS involving only one table, I'm fine.  The instant
I try to include other tables, either using a JOIN or a simple
table1.columnx=table2.columny in the WHERE clause, I get back an empty
result.  No errors are coming back via odbc_errormsg.

The query is:

$query = "SELECT bib_text.title_brief, bib_index.bib_id FROM bib_text,
bib_index WHERE  bib_index.bib_id=bib_text.bib_id AND
bib_index.index_code LIKE '%655%' AND bib_index.display_heading LIKE
'%Thesis%' AND bib_text.bib_format LIKE 'tm'" ;

$result = odbc_exec($connection, $query)  ;

Broken into two queries, I get results when I'm selecting the
appropriate data from just bib_text or bib_index.  The problem is when
I try to join them.  Again, the query works if I cut and paste in to
Access.  Some basic error reporting tells me that the $result variable
is empty.

Any help would be appreciated.
-- 
Mark Sandford
Special Formats Cataloger
William Paterson University
(973)270-2437
sandfordm1 at wpunj.edu


More information about the Web4lib mailing list