Sorry for that entry-level database question however i actually want to learn this.

I've two tables customer_change and customer_full and I wish to choose rows from customer_full that same customer(same customer_id) however with different customer_points.

I authored the next query:

SELECT * 
FROM customer_change a,customer_full b 
WHERE 
    a.ID = b.ID AND 
    a.CUSTOMER_POINTS != b.CUSTOMER_POINTS

Now it really works. However it will return rows both in tables, how could I alter the query to simply return the rows within the second table?

Also, the came back rows could have two rows that have a similar IDs, could I modify my query to simply range from the first row which has this ID?

Could experts offer outside assistance? Thanks!

The SQL inequality operator is <>, not !=. (Apologies: I observe that != is supported in a minimum of some implementations! Because the comments around the question have stated, it appears to become a character set problem. I uphold the relaxation of my answer, though. :))

Nevertheless, I suggest learning about JOIN syntax, instead of joining tables using WHERE criteria. The previous gives itself to more-readable queries, and allows you workout finer treatments for the way the tables are became a member of.

For instance, your query above could be:

SELECT * 
FROM customer_change a
JOIN customer_full b ON a.ID = b.ID AND a.CUSTOMER_POINTS <> b.CUSTOMER_POINTS

The * will choose everything which ends in the mix product of tables inside your query. You are able to "choose" specific posts by providing their title within the SELECT clause for example:

SELECT customer_points 
FROM customer_change

Or choose only posts from the specific table (or multiple tables) with the addition of the table title to the start of the column title then a period of time. For example:

SELECT customer_change.customer_points, customer_full.ID
FROM customer_change, customer_full

Inside your situation, you are able to choose Just the records within the second table:

SELECT b.* 
FROM customer_change a,customer_full b 
WHERE 
    a.ID = b.ID AND 
    a.CUSTOMER_POINTS != b.CUSTOMER_POINTS

Both <> and != are acceptable "not equals" operators.

Should you desired to use JOINs, you'll be able to do:

SELECT b.* 
FROM customer_change a
JOIN customer_full b ON a.ID = b.ID AND a.CUSTOMER_POINTS != b.CUSTOMER_POINTS