SQL with between in 2 columns statment


SQL with between in 2 columns statment



my data :


id a b price
1 2.00 1.00 2.50
2 2.00 2.00 3.00
3 3.00 1.00 4.50
4 3.00 2.00 2.50
5 3.00 3.00 3.00
6 4.00 1.00 4.50



my question is
how get data in id 2 to 4 with sql "between" from columns a and b not columns id


2 2.00 2.00 3.00
3 3.00 1.00 4.50
4 3.00 2.00 2.50



my code sql (but not work):


sql = "SELECT * FROM data_table WHERE (( BETWEEN (a = 2.00, b = 2.00 ) AND ( a = 3.00, b = 2.00 ))";




1 Answer
1



Not sure why you making the query complex. Try this


Select * from data_table where id between 2 and 4





not between id but from columns a and b
– iDea Brains
11 mins ago





do u want a between 2 and 4 or b between 2 and 4?
– Gaj
4 mins ago






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

.

How to generate build files in next js

Delphi Android file open failure with API 26