CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Cannot do inner join on DBI query

 



kaprikawn
New User

Oct 19, 2011, 4:20 AM

Post #1 of 1 (360 views)
Cannot do inner join on DBI query Can't Post

Hi, I'm using the DBI module, and it seems to show an error message when I try to join tables on the FROM clause. The following code does not work:

<code>

my $sql = $dbh -> prepare( " select a.field1 from table1 a inner join table2 b on a.id = b.id where a.id = 1 " );

$sql -> execute();

</code>

I get an error message reading:

<quote>

DBD::Oracle::db prepare failed: ORA-00933: SQL command not properly ended (DBD ERROR: error possibly near <*> indicator at ...

</quote>

Whereas the following works fine:

<code>

my $sql = $dbh -> prepare( " select a.field1 from table1 a, table2 b where a.id = b.id and a.id = 1 " );

$sql -> execute();

</code>

I really hate joining on the WHERE clause and consider it bad practice and would like to get to the bottom of this. Can anyone point me in the right direction as to how I can join on the FROM clause using the DBI module?

Thanks in advance.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives