Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6577661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:39:56+00:00 2026-05-25T15:39:56+00:00

Using PHP and mySQL. I have 4 total tables, AgencyInfo, TypeCodes, PrimarySta and MutualAid.

  • 0

Using PHP and mySQL. I have 4 total tables, AgencyInfo, TypeCodes, PrimarySta and MutualAid. AgencyInfo has unique ID as the primary. Typecodes has unique TID as the primary. PrimarySta and MutualAid have both ID and TID together as their primary key.

I’m trying to create a recordset that will give me records from PrimarySta and MutualAid based on a ID from agencyinfo. There are 47 static records in TypeCodes. PrimarySta and MutualAid will have 47 entries(typecodes) per ID. PrimarySta has ID, TID and 12 INT fields, MutualAid has the same ID, TID and 12 INT fields plus a 13th field(text) called notes.

I’m using a while loop to step through the data. ID is passed via POST or SESSION.

Page Layout
                               Primary Station
TypeCode              P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12
                               Mutual Aid
                      M1 M2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
Notes(M13)

This is repeated 47 times, once for each typecode. I used Dreamweaver to assemble my initial SQL Query, but from my research, it appears it may not be using the best syntax. I had the following code working with only 2 tables, TypeCodes and PrimarySta, but when I added in MutualAid, something broke.

$colname_Display = $_SESSION['sta_id']; }
mysql_select_db($database_DB, $MyDB);
$query_Display = sprintf("SELECT * FROM primarysta, typecodes, mutualaid 
WHERE primarysta.tid, mutualaid.tid = typecodes.tid AND primarysta.id = %s", 
GetSQLValueString($colname_Display, "int"));

I’m guessing my problem is with the primarysta.tid, mutualaid.tid = typecodes.tid line. I’ve seen INNER JOIN used, but can’t seem to get the syntax right.

Can anyone help me with proper syntax?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:39:57+00:00Added an answer on May 25, 2026 at 3:39 pm
    SELECT
        *
    FROM
        primarysta a
    INNER JOIN
        typecodes b
    ON
        a.tid = b.tid
    INNER JOIN
        mutualaid c
    ON 
        a.tid = c.tid
        and c.tid = b.tid
    WHERE 
        a.id = %s -- where the %s is your string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

using php and mysql I have two tables, a users table and a profiles
I'm using mysql/php/apache . I have the following situation: 2 tables where I need
Using PHP and MySQL, I have a forum system I'm trying to build. What
I am using php and mysql. I have a Database config file (db-config.php) which
I have a list of dates stored in MySQL using PHP. These were stored
I have been working on on an AJAX chat application using php, mysql. It's
(Using MySQL and PHP) I have a search form that will allow my users
I am using MYSQL and PHP. I have a table called item. Two of
I am using MySQL and PHP for a project I am working. I have
I have a product catalog using apache, php and mysql. I need to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.