how to compare heights values
Hi i want know how to compare the height with other user height here is my query
sele开发者_StackOverflowct * from tbl_Member where height between 3'8'' and 7'0'';
here height is other user height plz tell me correct query
Comparing values like 3'8''
and 7'0''
in the database would require a lot of parsing for each query and be rather slow. Store your values in a comparable way in the database, which in this case means an INT
column with values stored in centimeters. Put an index on it to make the query even faster. Then only convert to inches for display.
I know it's dirty, but here you go
select *
from tbl_Member
where
concat(format(left(height, 1), 0), lpad(format(substr(height,3,2), 0 ), 2, '0'))
between 308 and 700
3'8'' becomes 308 7'12'' becomes 712
You have to escape the single-quotes inside of the varchar strings as the single-quote character indicates the start or the end of the string:
SELECT *
FROM tbl_Member
WHERE height BETWEEN '3\'8\'\'' AND '7\'0\'\''
精彩评论