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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:55:25+00:00 2026-06-07T13:55:25+00:00

I have a game table like: CREATE TABLE game_piece( x Integer, y Integer, type

  • 0

I have a game table like:

CREATE TABLE game_piece(
  x Integer,
  y Integer,
  type Integer
);

Each (x,y) can only have 1 piece. Representing a grid (numbers being types):

1235
1134
9678

By connected I mean they have to be directly next to the origin in a vertical or horizontal fashion like:

 C   C=connected
COC  O=origin
 C

I’d like to check if there’s 3 pieces connected anywhere on the grid without needing to get the whole grid of the database and doing it in python, if there’s decent solution. Suggestions?

  • 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-07T13:55:26+00:00Added an answer on June 7, 2026 at 1:55 pm

    To clarify my comments on Xophmeister’s answer, like this:

    SELECT o.x, o.y
    FROM game_piece o
    JOIN game_piece p
    ON p.type = o.type
    AND (
      (o.x = p.x AND p.y IN (o.y-1,o.y+1))
      OR
      (o.y = p.y AND p.x IN (o.x-1,o.x+1))
    )
    GROUP BY o.x, o.y
    HAVING COUNT(*) > 1
    

    And here it is working on your test data: http://sqlfiddle.com/#!3/0bd34/1

    Edit: Since you only want to know if the condition exists, the best way to do it is to just shove LIMIT 1 on the end and see whether the query returns a result or not. For some reason sqlfiddle doesn’t like me putting the LIMIT in there, but I tested it on my server and it works just fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing the scores of my game CREATE TABLE Scores (
I have table named highscore like this: nameQL scoreQL piotr 50 And flash game
I would like to create multiple progress bars inside a grid or table through
I aim to create a browser game where players can set up buildings. Each
I am trying to create a database table for my game, and would like
I am trying to code a global lookup table of sorts. I have game
I have a games table which holds the data about a game. Then another
I'm developing a game. I want to have game entities each have their own
In Inform, I'd like to be able to create a new action, and have
I'd like to create an application that gets the ipv4 tcp table ( currently

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.