Solved

table output not working how i wish

Posted on 2007-04-10
6
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Business Impact of IT Communications

What are the business impacts of how well businesses communicate during an IT incident? Targeting, speed, and transparency all matter. Find out more in this infographic.

 
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

Is Your DevOps Pipeline Leaking?

Is your CI/CD pipeline a hodge-podge of randomly connected tools? You’ve likely got a tool to fix one problem & then a different tool to fix another, resulting in a cluster of tools with overlapping functionality. Learn how to optimize your pipeline with Gartner's recommendations

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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 …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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