![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
| |||
| 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 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |