Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Search

Status
Not open for further replies.

tempoman

Programmer
May 9, 2000
41
AU
I have a problem, that I can't seem to solve.<br>Basically I have two tables, Company and CompanyOwns.<br>What I am trying to do is pass a CompanyID into the database and it returns the Company. What also I want is to search for that CompanyID for companies it owns. <br>For example if the CompanyID was 2 and owns companyID 4,5.<br>Then the records I would like to return would be <br>2,4 and 5.<br><br>I have tried loops, arrays, lists but nothing seems to work it only returns the the last CompanyOwns record, e.g. 5 from the above example.<br><br>Can someone please help.
 
Try this:<br><br><FONT FACE=monospace><b><br>&lt;cfquery name=&quot;company&quot; datasource=&quot;mydb&quot;&gt;<br>&nbsp;&nbsp;Select * from Company <br>&nbsp;&nbsp;Where CompanyID=#CompanyID#<br>&lt;/cfquery&gt;<br><br>&lt;cfquery name=&quot;companyowns&quot; datasource=&quot;mydb&quot;&gt;<br>&nbsp;&nbsp;Select * from CompanyOwns<br>&nbsp;&nbsp;Where OwnerID=#CompanyID#<br>&lt;/cfquery&gt;<br><br>&lt;table&gt;<br><br>&nbsp;&nbsp;&lt;cfoutput query=&quot;company&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;#CompanyID#&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;#Name#&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;&lt;/cfoutput&gt;<br><br>&nbsp;&nbsp;&lt;cfif companyowns.recordcount&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;&lt;td colspan=2 bgcolor=&quot;ffffcc&quot;&gt;OWNS&lt;/td&gt;&lt;/tr&gt;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;cfoutput query=&quot;companyowns&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;#CompanyID#&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;td&gt;#Name#&lt;/td&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/tr&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/cfoutput&gt;<br><br>&nbsp;&nbsp;&lt;/cfif&gt;<br><br>&lt;/table&gt;<br></b></font><br>Hope this helps..<br><br>DM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top