Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with SQL Query syntax

Enthusiast ,
Jun 16, 2013 Jun 16, 2013

Just looking for a bit of help with an SQL query.

The table structure is:

table.Itineraries

ItineraryID, Itinerary, etc

table.Activities

ActivityID, Activity, etc

And an interlinking table

table.ItineraryActivities

ItineraryID, ActivityID

And I have a page here, listing Itineraries:

http://www.goodsafariguide.net/itineraries_beta/index101.php

That I would like to include some of the Activities on.

If it was just the first two tables, and tableActivities had an ItineraryID field, I assume it would be:

SELECT * FROM Itineraries INNER JOIN Activities ON Itineraries.ItineraryID = Activities.ItineraryID

But I'm not sure what the syntax would be to achive the same thing with the interlinking table as well.

Hope that makes sense.

Thanks.

TOPICS
Server side applications
832
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jun 16, 2013 Jun 16, 2013

I've nearly got it working using:

SELECT * FROM itineraries  INNER JOIN ItineraryActivities ON ItineraryActivities.ItineraryID = itineraries.ItineraryID INNER JOIN activities ON activities.ActivityID = ItineraryActivities.ActivityID WHERE Publish_GSG = 'Yes' AND Category_Order = 1

This is displaying the Acivities I want (in this case countries) here:

http://www.goodsafariguide.net/itineraries_beta/index501.php

Except that its displaying duplicate Itineraries, one for each country.

So all I need to do is get the little table with the countries to repeat within each itinerary, but usint DW's repeat region it doesn't like it because its nested.

Should I be able to somehow add a repeat regiona around:

<table>

      <tr>

           <td><img src="../../itinerary_resources/icons/<?php echo $row_SecurityAssisttradeusers['Icon']; ?>" width="30" height="20" alt="Country Flag" /></td>

           <td><h2><?php echo $row_SecurityAssisttradeusers['Activity']; ?></h2></td>

      </tr>

</table>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 17, 2013 Jun 17, 2013
LATEST

Just use a nested loop. The outer loop iterates through the iternerary recordset. That SQL only needs to select from the itererary table. The inner loop passes the itererary id to another sql that joins the link table to the activity table and the resulting recordset contains the related activities that can be displayed. Sounds like this is whay you have in mind, correct? So just plan to code this manually rather than using DW behaviors.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines