Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #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.

Reply With Quote

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

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

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

All times are GMT -4. The time now is 07:06 AM.

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