Jump to content

wondering how to select this


Shadowing
 Share

Recommended Posts

Hey guys i need to do a selection and not sure exactly how to do it.

 

 

I need to select x,y from planets where alliance is equal to the same and x and y is also equal to the same

 

 

so i have 15 rows for every x,y and im trying to see which set of 15 all share the same alliance name

Link to comment
Share on other sites

ya but im comparing to a unpredetermind value for the where clause

 

i want to select the x,y where all the alliances equal the same , and the x and y are the same

 

so all 3 columns need to be the same duplicate

 

the alliance column is blank in the example

 

 

 

 

planets_table.jpg

Link to comment
Share on other sites

sounds confusing how im wording this lol

 

 

im only wanting to select x1 y1 if all the columns that are x1 y1 all have the same alliance name

 

but i need it to search each set of x and y so i cant just say

 

select x,y from planets where x = 1 and y = 1 and alliance = "reavers"

Link to comment
Share on other sites

You can try this:

 

SELECT x, y, COUNT(*) AS CountRows, COUNT(DISTINCT alliance) AS CountAlliance
FROM planets
WHERE x = y
GROUP BY x, y
HAVING CountRows = CountAlliance 

 

Unfortunately, it is not going to give you the alliance value.

 

I may have misunderstood the requirements. This query returns rows where x = y. If you want any combination of x,y where all rows with that combination have the same alliance, you can take the WHERE clause out.

 

This query is going to scan the entire table. So, the more data you have, the slower it will be. (depending on indexes, etc).

 

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.