[thelist] sql statement

Dan McCullough dan.mccullough at gmail.com
Wed Mar 30 12:49:30 CST 2005


Does this monstrosity make sense.?

SELECT products.productid, products.name, products.action,
products.lg_picture, products.description, products.short, sizes.abrv
FROM products P INNER JOIN (prod_size PS ON S.sid = PS.sid WHERE
PS.productid = '"+productid+"' order by sort_order) ON
P.'"+rs.getString("short")+"' = P.productid) WHERE (((P.productid) =
'"+productid+"' order by P.sort_order));

I'm trying to combine three sql queries.  What its doing is taking a
productid, and looking up some basic information, from that tehre is a
field that points to another product, shorts, the shorts field in the
product table holds an id of the other product, and then finally the
part I am not sure will be doable in this query is querying the tables
from earlier in this thread,  "SELECT size.name FROM size S INNER JOIN
prod_size PS ON S.sid = PS.sid WHERE PS.prodid = 213".

Can that be done?  Should it be done?


On Wed, 30 Mar 2005 11:52:05 -0500, Dan McCullough
<dan.mccullough at gmail.com> wrote:
> I would be in the Dummies or Idiot standing at this point ... lol
> 
> 
> On Wed, 30 Mar 2005 08:30:13 -0800, Ed McCarroll <Ed at comsimplicity.com> wrote:
> > > Well in teh case of the address it should return a match or
> > > nothing
> >
> > Then you want an INNER JOIN.
> >
> > INNER JOINs are what you get if you imply the join in the WHERE
> > clause.  They are also implied if you just use JOIN without INNER,
> > OUTER, LEFT, etc.
> >
> > And if you haven't already, get a tutorial-style book on SQL.  I've
> > had good luck with books with titles like "Teach Yourself ... in 21
> > Days", "... Crash Course", and (last & least) "... For Dummies".
> >
> > --
> > Ed McCarroll                                  (310) 838-4330
> > Ed at ComSimplicity.com            http://www.ComSimplicity.com
> > --
> >
> > * * Please support the community that supports you.  * *
> > http://evolt.org/help_support_evolt/
> >
> > For unsubscribe and other options, including the Tip Harvester
> > and archives of thelist go to: http://lists.evolt.org
> > Workers of the Web, evolt !
> >
>


More information about the thelist mailing list