Solved

table output not working how i wish

Posted on 2007-04-10
6
187 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
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 
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

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

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
'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 …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

624 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