close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

SQL query help

Thread began 3/25/2014 8:35 am by iainmacdonald331081 | Last modified 3/26/2014 7:41 am by iainmacdonald331081 | 640 views | 5 replies

iainmacdonald331081

SQL query help

I currently have the following structure:

table: lodges
LodgeID (PK)
Lodge
LodgeDetails
etc

table: nominations
NominationID (PK)
Nomination
Category
Year
LodgeID
etc

table: scores
ScoreID (PK)
Score
ScoreYear
LodgeID
etc

table: trade_users
UserID (PK)
LodgeID
User
etc

And I have a page which lists any lodges which have either a 2015 Nomination or a 2015 Score (i.e. nominations.Year = 2015 OR scores.Year = 2015) for the currently logged in user using the following SQL:

SELECT DISTINCT lodges.LodgeID, Lodge, banner_image_new, Country, banner_image_new_title, photo_one, photo_one_title, Summary_2013, 2014_Nominee, GSG2014, Year, ScoreYear, Nominee, Finalist, HighlyCommended, RunnerUp, Winner, Category, 2015_Paid, 2015_Awards_Participant FROM lodges LEFT JOIN nominations ON lodges.LodgeID = nominations.LodgeID LEFT JOIN scores ON lodges.LodgeID = scores.LodgeID WHERE lodges.UserID = %s AND (Year = 2015 OR ScoreYear = 2015) ORDER BY Lodge ASC

Which works, but lists results:

Lodge A - Category 1
Lodge A Details

Lodge A - Category 2
Lodge A Details

Lodge A - Category 3
Lodge A Details

Lodge B - Category 1
Lodge B Details

etc

How could I change that to list the results in this way:

Lodge A
Category1, Category2, Category3
Lodge A Details

Lodge B
Category 2, Category 5
Lodge B Details

etc

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...