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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:40:37+00:00 2026-05-19T22:40:37+00:00

I have a MySQL table with following setup: CREATE TABLE IF NOT EXISTS `coords`

  • 0

I have a MySQL table with following setup:

CREATE TABLE IF NOT EXISTS `coords` (
  `project_id` int(4) NOT NULL,
  `day` tinyint(4) NOT NULL,
  `x` tinyint(4) NOT NULL,
  `y` tinyint(4) NOT NULL,
  `z` tinyint(4) NOT NULL,
  PRIMARY KEY (`tid`,`day`,`x`,`y`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Each project is running several days. Each day some cases are tested and the results (set of coordinates) are saved in this table (along with project id and day number). The same set of x and y coordinates can be saved more often than once (the z coordinate is the actual result).

Now I want to get all available sets of coordinates for a single project with the latest data available.

I.e., assuming I have following data:

pid | day | x | y | z
  1 |   1 | 2 | 1 | 5
  1 |   1 | 2 | 2 | 6
  1 |   2 | 3 | 3 | 7
  1 |   3 | 2 | 1 | 8
  1 |   3 | 3 | 3 | 9

The query shall now return:

day | x | y | z
  1 | 2 | 2 | 6
  3 | 2 | 1 | 8
  3 | 3 | 3 | 9

I was trying following query:

SELECT day, x, y, z 
FROM coords 
WHERE pid = 1 
GROUP BY CONCAT(tid,'.',x,'.',y) 
ORDER BY day DESC

But this query returns old data, just as day = 1, x|y|z = 2|1|5 instead of day = 3 and x|y|z = 2|1|8.

Could someone please point me in the right direction of what I am missing here?

Thanks in advance,
Paul

  • 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-19T22:40:38+00:00Added an answer on May 19, 2026 at 10:40 pm

    Try this out :).

    SELECT
      day,
      x,
      y,
      z 
    FROM
      coords
        JOIN
      (SELECT MAX(tid) AS max_tid FROM coords GROUP BY CONCAT_WS('.', day, x, y)) sub ON (sub.max_tid = coords.tid)
    WHERE
      pid = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following MySQL/InnoDB table. I added a compound index as the primary
Assume the following in MySQL: CREATE TABLE users ( id integer auto_increment primary key,
I have the following setup in MySQL: Table Game : gameid , p1state ,
I have a MySQL table with the following data (simplified): INSERT INTO `stores` (`storeId`,
I have the following Mysql Table Order table status 0 - incomplete status 1
I have the following MySQL table structure: num field company phone website 1 Gas
I have a following mysql table with a lot (3000+) of values: [id] [parent_id]
I have a MySQL table with a structure like the following: I'm looking for
I have three mysql table from same database Db1. Three tables have following columns.
I have the following table: mysql> SELECT * FROM `bright_promotion_earnings`; +----+----------+------------+----------+-------+ | id |

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.