[ic] Cascaded query against multiple tables

Dan Browning interchange-users@icdevgroup.org
Thu Jul 3 00:02:00 EDT 2003


* Mike Heins <mike@perusion.com> [2003-07-02 10:32]:
> Quoting Interchange User (interchange@framework.cx):
> > Greetings,
> > 	
> > IC 4.9.8 nightly, MySQL 4.1
> > 
> > I need to run a query against table1.  Based on what I find there, I  
> > need to take the results, and search with them against table2 and  
> > table3.
> > 
> > Table1 has a list of authors, with an index into articles they have  
> > written. I need to search the authors list for an author's name (via a  
> > text input), then, once I have that information, I need to hit table2  
> > and pull out all articles they have written, and table3, which contains  
> > supplemental information on the articles (which I can do with a join).   
> > I know I can do a join for the second query, but I don't know how to  
> > access the results from the second part of the query as search criteria  
> > using ITL.  Does anyone have any examples of this?
> > 
> > In MySQL, I would first
> > 
> > select articleid from nc_authorarticle where authordisplay like  
> > "%some_author's_name_here%";
> > 
> 
> This is just a MySQL question. Here is a query example that works
> on the IC foundation demo with MySQL 4:
> 
> <xmp>
> [query
>     list=1
>     table=products
>     sql=|
>         select p.sku,p.price,p.description
>         from products as p
>         where p.sku in (
>                 select m.sku from merchandising as m
>                 where m.featured = 'specials'
>               )
>     |
> ][sql-line]
> [/query]
> </xmp>
> 

Wow, I had no idea they added sub-queries in 4.1.  That's great.
-- 
Dan Browning, Kavod Technologies, <db@kavod.com> 360.843.4074x217
6700 NE 162nd Ave, Ste 611-210, Vancouver, WA.    Random Fortune:
Never explain.  Your friends do not need it and your enemies will never
believe you anyway.
		-- Elbert Hubbard



More information about the interchange-users mailing list