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

  • Home
  • SEARCH
  • 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 8678905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:50:22+00:00 2026-06-12T20:50:22+00:00

I am trying to make a select statement and I just cant get it

  • 0

I am trying to make a select statement and I just cant get it work.

I have 3 tables:
places, tags, places_tags

Places:
   - id
   - name

Tags:
   - id
   - name

Places_tags:
   - place_id
   - tag_id
   - order

I am trying to select places and join the first tag that inserted (using order)

        SELECT p.*, t.tag_id AS tag
        FROM `places` as p
        LEFT JOIN places_tags t ON (t.place_id = p.id)
        group by p.id

That’s what I have right now.
I need to add somthing like ORDER BY order DESC…

I think that I’m not doing it right.

  • 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-06-12T20:50:23+00:00Added an answer on June 12, 2026 at 8:50 pm

    Something like the following should work:

    SELECT 
       p.name AS "place", 
       t.name AS "firstTag" 
    FROM 
       places p 
       LEFT JOIN
       places_tags pt1 
          ON pt1.place_id = p.id
       LEFT JOIN
       places_tags pt2 
          ON pt2.place_id = p.id AND pt2.tag_id < pt1.tag_id
       LEFT JOIN 
       tags t 
          ON t.id = pt1.tag_id
    WHERE
       pt2.tag_id IS NULL
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have this select statement that I am trying to make more responsive.
I'm trying to get a mysql PDO statement to select all of the failed
I am trying to make update statement in MySql table - just migrating data
I am trying to make a form using two drop down select menus: one
1st Question: I'm trying to make the create method work, but it appears that
So I recently have been trying to incorporate more sub forms to make the
I have 3 tables: products, products_description, products_to_categories Here is my sql: SELECT `products`.`products_model`, `products_description`.`products_name`
I'm just trying to make a simple function that will return all the data
I have the following sql statement - it's trying to find all the zipcodes
I'm trying to write a statement that will check 2 tables and compare the

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.