SunQuest
 
           General SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesGeneral SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old September 10th, 2006, 04:26 PM
kitus kitus is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 1 kitus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 8 sec
Reputation Power: 0
Show info from 2 tables

Hi !

I need some help. I'd like to show information from 2 tables . One is called categories and the other one id called subcategories. I need to show the information this way :

category1
--------
subcategory1
subcategory2
subcategory3
...

category2
--------
subcategory1
subcategory2
subcategory3
...

any help ?

thanks !!!

Reply With Quote
  #2  
Old September 11th, 2006, 03:26 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 956 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2Folding Points: 672951 Folding Title: Super Ultimate Folder - Level 2
Time spent in forums: 6 Days 8 h 23 m 32 sec
Reputation Power: 4
Send a message via ICQ to Itsacon
SQL Code:
Original - SQL Code
  1. SELECT *
  2. FROM categories INNER JOIN subcategories
  3.     ON (categories.id = subcategories.category_id)
  4. ORDER BY category.name, subcategory.name;


Next, in the code where you read the sql results, keep track of the category you're currently outputting. If it's a different one from the last, print a new header. If not, print only the subcategory name.
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 264

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesGeneral SQL Development > Show info from 2 tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway