示例:
ID | User | Name
1 | Usr1 | First User Name
2 | Usr2 | Another User Name
如何从USER中选择名称为max = 7
的NAMEName from Usr1 = "First U"
Name from Usr2 = "Another"
答案 0 :(得分:1)
只需使用LEFT
mysql函数。
SELECT left(name, 7) FROM user
答案 1 :(得分:1)
我真的不明白这个问题,但这就是我所拥有的:
如果你想获得 NAME with 7 char ,那么这里是语法:
SELECT NAME FROM USER
WHERE CHAR_LENGTH(NAME) = 7
现在,如果你想获得前7 字符,这里是语法:
SELECT LEFT(NAME, 7) FROM USER;