sql join

Post Reply
sourceuno
Posts: 225
Joined: Mon Apr 09, 2001 3:58 pm

sql join

Post by sourceuno »

I'm trying to perform a join with 2 tables and check if the 1st table's id exists in a 3rd table. Here's my query:

<$sqlstr="select tbl1.id,tbl2.url from tbl1,tbl2
where tbl1.joinfield=tbl2.joinfield and tbl1.id in (select distinct(id) from tbl3)">

<sql max=50 $sqlstr>
$url<BR>
</sql>

I ran this query in Vortex and get the following error in the error log:
000 May 31 18:19:50 /vortex/test:18: Strange value in p->rt: 33554476 in the function setprednames
000 May 31 18:19:50 /vortex/test:18: Monitor ABEND exception 0xC0000005 (ACCESS_VIOLATION)

Am I writing my query incorrectly?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

sql join

Post by mark »

You can't mix subqueries and joins. There are any number of ways to recode your query depending on your needs. Here's one way:

<sql row "select distinct(id) id from tbl3">
<sql max=50 row "select tbl1.id,tbl2.url from tbl1,tbl2 where tbl1.joinfield=tbl2.joinfield and tbl1.id=$id">
$url<br>
</sql>
</sql>

I assume that tbl2 is being used as a limiting factor since it's not needed otherwise.
Post Reply