Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
| Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 10th, 2006, 09:37 PM
Registered User
 
Join Date: Jan 2006
Location: jakarta, , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to will2kready
Default Need help : how to query multiple categories


I have a structure tables that already run ads system for long time. When post an ad, it is only can choose single category. Now we are planning to make it in multiple categories, so one ad can have many categories.

Table XcCpClassifieds :

CadID (autonumber) | CadCatID (number) | CadTitle (text) | CadDesc (text) | CadCreated (date)

Because the CadCatID field is in number, so I try to add another table called multicat:

Table Multicat :

CadID | CadCatID

So when someone post an ad with multiple categories choosen, then it insert to Table XcCpClassifieds’s CadCatID field as 0, and insert all the categories id in Table Multicat , ex:

Table XcCpClassifieds :
CadID | CadCatID | CadTitle | CadDesc | CadCreated
235 | 0 | test | test | 01/11/2006

Table Multicat :
CadID | CadCatID
235 | 5
235 | 12
235 | 4

And when someone post ad ad with single category, then just insert to Table XcCpClassifieds ex:
Table XcCpClassifieds :
CadID | CadCatID | CadTitle | CadDesc | CadCreated
235 | 5 | test | test | 01/11/2006

Now my problem is, im getting difficult to display all the ads in each category, what is the query looks like, maybe using UNION ? or any other suggestion. Now the ads displayed for each category, the problem I have is when it read from XcCpClassifieds, found the cadCatID is 0. what sql statement to join these tables ? and display all the ads (single cat and multiple cat ads).im running in MSSQL database.Thanks a lot.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Sub Categories for Forum- tectrix BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 9 May 21st, 2008 05:25 PM
Wrox Blog - Multiple Categories suggestions madAlan BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 January 28th, 2007 06:39 PM
Unlimited categories golden_drifter Access 2 August 31st, 2006 07:21 AM
Deleting Categories spardoe BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 July 19th, 2006 03:07 AM
Multiple Joins in Multiple Table Search query pookster Access 4 September 23rd, 2004 03:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.