Monday 3 September 2018

The Mysql query does not work with mathematical operators

Where is a problem because I try count values using sql queries:

(SELECT quantity FROM db WHERE no='998') this is fine
but (('500') - (SELECT quantity FROM db WHERE no='998')) // incorrect syntax near -
But I need to use constant 500. Where is problem

How about this?
SELECT 500 - quantity
FROM db
WHERE no = 998;

select statement needs to start with a select. In addition, numeric constants should not use single quotes (although that has no effect on whether the query parses or runs).

0 comments:

Post a Comment