in reply to Dereferencing nested references

Aside from what repson and chipmunk say, I think another problem here is with your SQL query. Why aren't you using a JOIN?

SELECT * FROM buyerssellers,people WHERE filenumber=? AND buyersellers.personid = people.personid

lets your database do most of the work (which is almost always a Good Thing.) Also by using placeholders (the '?' in the query), you no longer have to do a seperate prepare for every iteration. This could save you a lot of time.

Replies are listed 'Best First'.
Re: Re: Dereferencing nested references
by ryddler (Monk) on Jan 16, 2001 at 19:57 UTC
    Mainly I wasn't using a JOIN because I haven't done much database work, and am not familiar with all that can be done with SQL calls. After breaking down your statement I can see where it would be very efficient, unfortunately in my case the second table may not have any data when I make the calls, and I still need to return the info from the first table regardless. It looks to me like this statement will return "all or nothing." Is this true?

    ryddler
      ryddler, you'll just have to ponder SQL a little bit harder. Because, you can make outer joins as well. Generally:
      SELECT name, 'In table2!' FROM table1 WHERE ID IN (SELECT ID FROM table2) JOIN SELECT name, 'Not in table2!' FROM table1 WHERE NOT ID IN (SELECT ID FROM table2);
      Well, this isn't beautiful SQL either, as you write two subselects, but it gets the job done. Whatever the columns and order in which you want it be returned, it really can be done in SQL. Look here for a tutorial.

      Jeroen
      "We are not alone"(FZ)