Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-26-2006, 03:00 PM
hja
 
Posts: n/a
Default Complicated "CASE WHEN" query for Dreamweaver Recordset

Hello,

I have a table called "categories_ctg" with the following fields:
id_ctg, int(11), auto_increment
idctg_ctg, int(11)(can be NULL)
name_ctg, varchar(100)
longname_ctg, varchar(255)
order_ctg, int(11)

The table is stored for categories, for instance
1, NULL, hardware, hardware, 1
2,1,computers,computer systems,2
3,1,printers,printers,3
4,NULL,software,software,4

I use this to navigate on a website. What I want is to show the above al
follows:

hardware > computers
hardware > printers
software

The query I've tried is:
SELECT subcategories_ctg.id_ctg, CASE WHEN categories_ctg.name_ctg IS NULL
THEN subcategories_ctg.name_ctg ELSE categories_ctg.name_ctg, ' > ',
subcategories_ctg.name_ctg END as name_ctg
FROM categories_ctg, subcategories_ctg LEFT JOIN categories_ctg ON
subcategories_ctg.idctg_ctg=categories_ctg.id_ctg
ORDER BY name_ctg

But this gives the following error on a browser output:
"There is something wrong in the syntax at ' ' > ',
subcategories_ctg.name_ctg END as name_ctg FROM categori' at line 1.

I am using Dreamweaver (8.02) to edit the queries, where get a MySQL
error:#1064.
If anybody could tell me how to get the desired result, I'll be grateful,
since I'm not a real specialist and I've been trying this for 3 days now .

Greetings,
HJA



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:36 AM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.