Solved

table output not working how i wish

Posted on 2007-04-10
6
181 Views
Last Modified: 2010-03-20
i want my table output to work like so....

a department (department.name)
- category in this department (categories .name)
- another category in this department (categories .name)
 
etc

but the isses i have (i think) is that they are both called name

i have this so far...

<cfquery name="ArtCategories">      
                  SELECT d.name, d.depId, d.pos, c.name, c.catId
                  FROM departments d
                  INNER JOIN categories c
                  ON c.depId = d.depId
                  ORDER BY d.pos
                  </cfquery>

                  <cfoutput query="ArtCategories" group="name">
                        <h3>#name#</h3>
                        <cfoutput>
                        <p>#name#</p>
                        
                        </cfoutput>
                  </cfoutput>
0
Comment
Question by:pigmentarts
  • 3
  • 3
6 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 18882910
the fact that both columns are called name should not be a problem and your query should work
what is the problem you encounter ?
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 18882941
the error is...

 Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]The column prefix 'c' does not match with a table name or alias name used in the query.

0
 
LVL 12

Author Comment

by:pigmentarts
ID: 18882962
sorry there is no error (sorted that) i just get the wrong results i get

a department say baths
then it just repeats 2x
-baths
-baths


where i want

baths (department )
- Corner Baths (cat)
- Whirlpool Systems (cat)

0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 37

Expert Comment

by:momi_sabag
ID: 18883014
in order to get the formatted output you want , try this

select name
from (
SELECT 1 as cola, depid, name                
FROM departments d
union all
select 2 as cola, depid, name
from categories
) as t
order by col1,depid
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 18883106
[Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name 'col1'.

0
 
LVL 37

Accepted Solution

by:
momi_sabag earned 500 total points
ID: 18883280
sorry

select name
from (
SELECT 1 as cola, depid, name                
FROM departments d
union all
select 2 as cola, depid, name
from categories
) as t
order by cola,depid
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now