I have a set of nested links, and at one time each category one had all the
same subcategories. Now that has changed - each category has different
subcategories. I have a tree menu, but now it just shows all subs under
each category, of course. I have 2 tables - one for categories, one for
subcategories - they are related by the categoryID. I think I have the SQL
fine (have tried several different versions - see most recent/uncluttered
below), but how do I get it to work correctly in the tree loop?
SELECT DISTINCT cat.catName, cat.catDesc, subcat.subcatName
FROM cat, subcat
WHERE cat.catID = subcat.catID;
Tree example:
cat.catName(1)
subcat.subcatName(1)
subcat.subcatName(2)
cat.catName(2)
subcat.subcatName(3)
subcat.subcatName(4)
I'm sure it must be simple, and I'm just having a slow brain day...
Thanks,
Chris 2 2423
Chris wrote: I have a set of nested links, and at one time each category one had all the same subcategories. Now that has changed - each category has different subcategories. I have a tree menu, but now it just shows all subs under each category, of course. I have 2 tables - one for categories, one for subcategories - they are related by the categoryID. I think I have the SQL fine (have tried several different versions - see most recent/uncluttered below), but how do I get it to work correctly in the tree loop? SELECT DISTINCT cat.catName, cat.catDesc, subcat.subcatName FROM cat, subcat WHERE cat.catID = subcat.catID;
Tree example: cat.catName(1) subcat.subcatName(1) subcat.subcatName(2)
cat.catName(2) subcat.subcatName(3) subcat.subcatName(4)
I'm sure it must be simple, and I'm just having a slow brain day...
Thanks, Chris
Does this help: http://dev.mysql.com/tech-resources/...ical-data.html
SELECT cat.catName, cat.catDesc, subcat.subcatName
FROM cat
LEFT JOIN subcat ON subcat.catID = cat.catID
ORDER BY catID ASC
-- http://blog.deshot.com http://www.padbuilder.com
Chris wrote: I have a set of nested links, and at one time each category one had all the same subcategories. Now that has changed - each category has different subcategories. I have a tree menu, but now it just shows all subs under each category, of course. I have 2 tables - one for categories, one for subcategories - they are related by the categoryID. I think I have the SQL fine (have tried several different versions - see most recent/uncluttered below), but how do I get it to work correctly in the tree loop?
SELECT DISTINCT cat.catName, cat.catDesc, subcat.subcatName FROM cat, subcat WHERE cat.catID = subcat.catID;
Tree example: cat.catName(1) subcat.subcatName(1) subcat.subcatName(2)
cat.catName(2) subcat.subcatName(3) subcat.subcatName(4)
I'm sure it must be simple, and I'm just having a slow brain day...
Thanks, Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Simon |
last post by:
Hi,
I am having a little problem with my PHP - MySQl code, I have two tables
(shown below) and I am trying populate a template page with data from both.
<disclaimer>Now I would like to say my...
|
by: Afkamm |
last post by:
I can't get my head around them.
I have two MySQL tables, one contains the categories, the other contains
the posts. Each post is linked to a category.
Now I'm trying to display each post with...
|
by: Charles Alexander |
last post by:
Hello
I am new to php & MySQL - I am trying to retrieve some records from a MySQL
table and redisplay them. The data in list form looks like this:
Sample_ID Marker_ID Variation
...
|
by: John Wilson |
last post by:
Hello,
I have the following code which populates as table data from a SQL
Server 2000 stored proc (RSByDemoID2). Below that is the view and
stored procedure which takes @DemoID as input to match...
|
by: Peter Olcott |
last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html
Why is C# 500% slower than C++ on Nested Loops ???
Will this problem be solved in...
|
by: Peter Olcott |
last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html
The above link shows that C# is 450% slower on something as simple as a nested
loop....
|
by: BMeyer |
last post by:
I have been losing my mind trying to parse an XML document (with nested child
elements, not all of which appear in each parent node) into a DataGrid
object. What I want to do is "flatten" the XML...
|
by: th3dude |
last post by:
I am trying to pull out some nested XML using C# and XMLReader.
Can't seem to extract the "Items" for each "Product" when i loop
through file, i can loop over the "Product" notes just fine but...
|
by: toddlahman |
last post by:
I am using two while loops that are nested. The first loop (post name)
returns the full column of results, but the second (post modified)
only returns the first row of the column. Is there another...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |