Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql left join count
    primarykey
    data
    text
    <p>My question relates to a game I'm writing in the game items, the badguys bodies, and coins drop on the ground at a specific x,y coordinate of a land when a group of items is on a tile the game will show a treasure icon. its important that I count how many so when a player picks them up it will be removed if the player takes them all. There are other ways to do this but the method I'm using suits my application well.</p> <p>So I need to join 3 tables on fields x, y, land and count the number of occurances of each combination and coins are stored as their value so I would like to count each coin (in other words add value to count) so I have tables as follows in all tables posx,posy, land are grounped as table name: game_coins fields: posx, posy, land, value &lt;-- counts as # stored in value</p> <pre><code>table name: game_items fields: posx, posy, land, item_id &lt;--counts as 1 table name: game_corpses fields: posx, posy, land, id &lt;-- counts as 1 </code></pre> <p>Here is the query I used so far I get an ambiguous error and I know what that means but it seems like I should be able to call all the tables with 1 column name if they are the same and I'm grouping by that column</p> <pre><code>SELECT posx, posy, land, COUNT(*) as 'count' FROM game_itemlist LEFT JOIN game_corpses ON posx, posy, land LEFT JOIN game_coins ON posx,posy,land WHERE land = 'test' GROUP BY posx, posy, land </code></pre> <p>I could add value to count afterwords but I can't get the left join correct. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload