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
Solved

table output not working how i wish

Posted on 2007-04-10
6
184 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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