Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

table output not working how i wish

Posted on 2007-04-10
6
Medium Priority
?
189 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

705 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