This could not work as the quantity of row 2 is also not the same as other of row 1.
At the end you do not need a join at all. Why not still use
SELECT t1.ID FROM table1 t1 WHERE t1.qty != t1.other
If you absolutely need to use a join (which really makes no sense) you need some unique identifier in your rows. I do not know why your id is always 1. normally an Id column is a unique primary key with Auto increment. In that case you would have your unique identifier of the row and could use
SELECT t1.ID FROM table1 t1 INNER JOIN table1 t2 ON t1.Id = t2.Id AND t1.qty != t2.other
How your table looks at the moment you could also use
SELECT t1.ID FROM table1 t1 INNER JOIN table1 t2 ON t1.name = t2.name AND t1.qty != t2.other
But this would recommend that each fruit is only one time in the table.
Trying to use a join here is going to cause some issues, as Thallius points out; the excessive join conditions makes it functionally inefficient to join the table to itself to do a simple comparison between columns in the same row.
You should only be thinking about joins if you needed to compare things in different rows.
Even that won’t work if the id (or even id and name, which looks to more likely to be the PK for that table) isn’t accounted for because id 2 records would get compared to id 1 records and so on. The join just isn’t the right thing here at all, nor needed. A simple where would do.
That very well could be. I was basing my comment on the expected output in the original post, but the point is accurate.
Do Mango, Banana and Apple all have the same IDs, or was that just quick dummy data.
If the ID is the same, do they want to see 1 because the sums aren’t equal (10+12+5) != (9+12+5), or the individual record where 10 !=9? If the second, then shouldn’t the name show as well to make it clearer what is being looked at?
@wawane7256, we could use some clarity on your data source, and more detail on what the end result should be.