Re: cfquery select question

2011-05-27 Thread Maureen
Mark, there is an excellent SQL tutorial here: http://www.w3schools.com/sql/ If you figure out exactly how joins work, it will make writing SQL so much easier for you. Sub-selects like Greg used are also very useful. A few hours spent on this site will save you hours of struggle later. On

cfquery select question

2011-05-26 Thread Mark Atkinson
Hallo all, Forgive my SQL injection into this list - perhaps an answer to my question might also prove useful to others. I'm using three tables. There is no relationship between table1 and table3. I first query table1 for ordernumber and productcode, based on the productcode containing a

Re: cfquery select question

2011-05-26 Thread John M Bliss
SELECT DISTINCT table3.ID, table3.Company FROM table3 INNER JOIN table2 ON table3.ID = table2.t2_ID INNER JOIN table1 ON table2.ordernumber = table1.ordernumber WHERE (table1.productcode LIKE '%a certain string%') On Thu, May 26, 2011 at

Re: cfquery select question

2011-05-26 Thread Greg Morphis
If they all return 1 row use this.. select * from table3 t3 where t3.ID = ( select t2.ID from table2 t2 where t2.productcode = ( select t1.productcode from table1 t1 where t1.ordernumber = [whatever] ) ) If they

RE: cfquery select question

2011-05-26 Thread Mark Atkinson
it to produce the same results, which I will do. Thanks again, Mark -Original Message- From: Greg Morphis [mailto:gmorp...@gmail.com] Sent: Thursday, May 26, 2011 11:48 AM To: cf-talk Subject: Re: cfquery select question If they all return 1 row use this.. select * from table3 t3 where t3.ID