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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying all values between two or more table relations...

Status
Not open for further replies.

WaZiR006

Technical User
Oct 20, 2000
11
0
0
CA
Hi Guys,

If anyone can help me out i'd appreciate it. Here is the thing, i have two tables "news" and "GC" where "news.ID=GC.NID" !

For example if in the news table i have:

ID(auto-number) NewsTitle
2 blah blah blah blha!

and then in the GC table:

ID(auto-number) NID Category
1 2 cat1
2 2 cat2
3 2 cat3

And i've already setup the table relations where News.ID=GC.NID, what would my Query look like? I want all the results listed under ID "2" in table GC to show in one line rather than multiple lines.

The Query i have now is like this:

<CFQUERY DATASOURCE=&quot;#DNS#&quot; name=&quot;datab&quot;>
SELECT *
FROM News, GC
WHERE News.ID=GC.NID
</CFQUERY>

and then ofcourse i have the CFOUTPUT tag later on to show values, but it doesn't work! It shows the values in multiple lines. What am i doing wrong??


Situation #2:

Ok Now aside from my problem #1, lets say i have all the values in simular tables as said above. And im updating the values, So i want to recall the data and have it put a check mark beside that option?

What i mean is lets say for News.ID #2 i got results from GC table(cat1, cat2, cat3) and now i want it to put a checkmark beside those checkboxes that have the same name?? Is it possible??? Doesn't have to be a check mark option, could be an expanded dropdown list. Can it be done?


I posted two problems, please feel free to answer any; thank you TONS in advance! :)

Brad

 
Hey Brad,

For question #1, I think this will do what you want.

<CFQUERY DATASOURCE=&quot;#DNS#&quot; name=&quot;datab&quot;>
SELECT *
FROM News, GC
WHERE News.ID=GC.NID
ORDER BY news.id
</CFQUERY>

<table>
<cfoutput query=&quot;datab&quot; group=&quot;id&quot;>
<tr><td>#NewsTitle#</td><td><cfoutput>#category#</cfoutput></td></tr>
</cfoutput>
</table>

By doing a grouping in your query, you can in essence nest <cfoutput> tags with the &quot;group&quot; attribute.

For question #2, I explained how to do this type of update yesterday for Skenj. Take a look at his question title &quot;How Are Those Pesky Values Passed?&quot; located here
Hope this helps,
GJ
 
STill having a problem...

Not for calling from one field that worked GREAT! :) Thank you so much... But i wanted it to do it from multiple tables. I thought i could do it after figuring out how to do it with one, but it doesn't work. Like im using ur CFquery, except there are 3 more tables &quot;RE, LS, BS&quot;

so my new query is :

<CFQUERY DATASOURCE=&quot;#DNS#&quot; name=&quot;datab&quot;>
SELECT *
FROM News, GC, RE, LS, BS
WHERE News.ID=GC.NID or News.ID=RE.NID or News.ID=LS.NID or News.ID=BS.NID
ORDER BY news.id
</CFQUERY>

What am i doing wrong?? What should my query and CFOUTPUT look like now ??? Im sorry to be such a pain. I'm just learning CF, and i keep missing out on simple things! :(

Thank you in advance for ANY help you may be! :)

Brad
 
Sorry guys, i need to bump my msg up for someone to see, i really need to findout how to do this. If anyone can help me out, i'd really appreciate it. :)


Brad
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top