如何让℅从一个表中某一列

时间:2022-08-04 22:13:35

I have a table called students with a column marks, the data in the marks column is like 80,90,70%,50%,30.
How do I get the data from marks column which is like 70%,50%.

我有一个表格叫做学生,有一个列标记,标记列中的数据是80 90 70% 50% 30。如何从标记列中获取数据大概是70% 50%

4 个解决方案

#1


2  

Assuming data type of marks is varchar.

假设标记的数据类型为varchar。

 select marks from students where marks like'%\%' escape '\'; 

#2


1  

You should escape % sing within WHERE clause.

您应该在WHERE子句中转义% sing。

Try following

尝试后

SELECT * 
FROM students 
WHERE marks LIKE '70[%]%' 
OR marks LIKE '50[%]%'

#3


1  

You can use LIKE operator,

你可以用像运算符,

SELECT * FROM students WHERE marks LIKE '\%%'

#4


1  

SELECT * FROM students(
WHERE marks LIKE '%\%')
/

In above code first % will be treated as wildcard which means it will try to find any character. Next % is actual string '%' (since it has escape character '/'). So query will return any character followed by '%'

在上面的代码中,%将被视为通配符,这意味着它将尝试查找任何字符。下一个%是实际的字符串'%'(因为它有转义字符'/')。那么查询将返回任何后跟'%'的字符

#1


2  

Assuming data type of marks is varchar.

假设标记的数据类型为varchar。

 select marks from students where marks like'%\%' escape '\'; 

#2


1  

You should escape % sing within WHERE clause.

您应该在WHERE子句中转义% sing。

Try following

尝试后

SELECT * 
FROM students 
WHERE marks LIKE '70[%]%' 
OR marks LIKE '50[%]%'

#3


1  

You can use LIKE operator,

你可以用像运算符,

SELECT * FROM students WHERE marks LIKE '\%%'

#4


1  

SELECT * FROM students(
WHERE marks LIKE '%\%')
/

In above code first % will be treated as wildcard which means it will try to find any character. Next % is actual string '%' (since it has escape character '/'). So query will return any character followed by '%'

在上面的代码中,%将被视为通配符,这意味着它将尝试查找任何字符。下一个%是实际的字符串'%'(因为它有转义字符'/')。那么查询将返回任何后跟'%'的字符