I'm newbie in SQL, I wonder if its possible to compare the values of two columns in the same row(s) using MYSQL.

e.g. I have a table called "Table" with two columns "data_a" and "data_b" which both are (int)

I want to get "data_a" value bigger than "data_b" value .

data_a   data_b
10        5
6         4
2         8
1         9

First of all, you shouldn't call "table" your table as it is a reserved word and can cause some confusion.

Have you read any documentation about querying ? You should start from here Query information

If you want to select all rows where data_a is bigger than data_b you can do it with

SELECT * FROM table where data_a > data_b

You can simply write query :

SELECT * FROM table WHERE data_a > data_b;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.