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 723387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:06:08+00:00 2026-05-14T06:06:08+00:00

I am a little confused on the logic of how to write this SQL

  • 0

I am a little confused on the logic of how to write this SQL statement. When a user clicks on a tag, say HTML, it would display all the posts with HTML as its tag. (a post can have multiple tags)

I have three tables:

  1. Posting–>posting_id, title, detail,
    etc
  2. tags–>tagID, tagname
  3. postingtag–>posting_id, tagID

I want to display all the title of the post and the date added.

    global $dbc;
    $tagID=$_GET['tagID']; //the GET is set by URL

    //part I need help with. I need another WHERE statment to get to the posting table
    $query = "SELECT p.title,p.date_added, t.tagname FROM posting as p, 
    postingtag as pt, tags as t WHERE t.tagID=$tagID";

   $data = mysqli_query($dbc, $query);

  echo '<table>';
  echo '<tr><td><b>Title</b></td><td><b>Date Posted</b></td></tr>';
  while ($row = mysqli_fetch_array($data)) {         
     echo '<tr><td>'.$row['title'].'</td>';
     echo '<td>'.$row['date_added'].'</td></tr>';
     }
  echo '</table>';
}

I am fairly new to mySQL so still trying to figure out the logic of it all 🙂

  • 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-14T06:06:09+00:00Added an answer on May 14, 2026 at 6:06 am

    This is more clearly written using ANSI syntax:

    select p.title, p.date_added, t.tagname 
    from posting p
    inner join postingtag pt on p.postingID = pt.postingID
    inner join tags t on pt.tagID = t.tagID
    where t.tagID=$tagID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a little confused. How would I go about producing this in embedded ruby?
I am a little confused about Accept-Encoding . I have Web Service which would
I'm a little confused with the outcome of these strtotime functions, I would expect
Little confused, the basic spring mvc app has this: app-config.xml <context:component-scan base-package=org.springframework.samples.mvc.basic /> and
I am getting confused between domain/application logic and User Interface logic. To illustrate what
Quickie-Question: To summarize, I'm a little confused as to how I would design such
Got little confused with MVVM and user control events. I have a user control
I'm a little bit confused here. I have 2 models: User Ticket A Ticket
I am a little bit confused on exactly how to program this. I have
This seemed easier in Web Forms; I'd have a user control, with the logic

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.