php - MYSQL - get the rows where one column A is less than column B


Table (showing only relevant columns)

ID | product_name | stock | stock_level
6  | test name    | 5     | 4
 7 | test name 2  | 3     | 9

I have a lot more rows in my database.

In MYSQL, how can I get every row where the stock value is less than the stock_level value?




Like this?

SELECT * FROM table WHERE stock < stock_level

That would return row2 (stock = 3, stock_level= 9) but not row1 (stock = 5, stock_level= 4).

$result = mysqli_query($myslqi, "SELECT * FROM table WHERE stock < stock_level")) {

People are also looking for solutions to the problem: php - 301 redirection to changed urls


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.