Home > database >  Mysql in select count (*) from the user where the username='% % ss' query returns a value
Mysql in select count (*) from the user where the username='% % ss' query returns a value

Time:09-16

I as title in navicat SQL query but get a 0, but I have multiple tables inside the username is the record of ss, if use select count (*) from the user where the username='s' this statement returns is 10, why get is 0, anyone know

CodePudding user response:

Has anybody ever understand themselves placed at the top

CodePudding user response:

To sink, bearer

CodePudding user response:

Is there a great god!

CodePudding user response:

Select count (*) from the user where the username='% % ss'
-

The possible reason is: the equal sign (=),
Wildcard mean "like,,,," is not accurate, should use the like, can't use said strict equal sign, try this:

Select count (*) from the user where the username LIKE '% % ss'


CodePudding user response:

The
reference 4 floor mich2017 reply:
select count (*) from the user where the username='% % ss'
-

The possible reason is: the equal sign (=),
Wildcard mean "like,,,," is not accurate, should use the like, can't use said strict equal sign, try this:

Select count (*) from the user where the username LIKE '% % ss'

Hello, I have known the problem is the issue of the equal sign, but now I had a similar problem, and I in the data table with a select Count (*) from the user where the user. The sex=1 and the user. The username like '% % xiao Ming this query query to get a value of 3, then I do a test with mybatis got a null;
This is & lt; Select id="findCount parameterType=" User_UserCustom_vo "resultType"="userCustom & gt;"
Select Count (*) from the user where the user. The sex=# {userCustom. Sex} and the user. The username like '% % ${userCustom. Username}
The query set into a value of 1 and xiao Ming, why I can get the value in data table query, but in mybatis query to null
This is the method of the test
@ Test
Public void testFindCount () throws the Exception
{
SqlSession session.=sqlSessionFactory openSession ();
UserMapper UserMapper=session. GetMapper (UserMapper. Class);
UserCustom UserCustom=new UserCustom ();
UserCustom. SetSex (" 1 ");
UserCustom. SetUsername (" Ming ");
User_UserCustom_vo User_UserCustom_vo=new User_UserCustom_vo ();
User_UserCustom_vo. SetUserCustom (userCustom);
Int I=userMapper. FindCount (user_UserCustom_vo);
System. Err. Println (I);
}
This is User_UserCustom_vo class
Public class User_UserCustom_vo {
Private List The ids.


Public List GetIds () {
Return the ids;
}

Public void setIds (List Ids) {
Enclosing the ids=ids;
}

Private UserCustom UserCustom;

Public UserCustom getUserCustom () {
Return userCustom;
}

Public void setUserCustom (UserCustom UserCustom) {
Enclosing userCustom=userCustom;
}

}

CodePudding user response:

reference 5 floor l1445453337 reply:
Quote: refer to 4th floor mich2017 response:

Select count (*) from the user where the username='% % ss'
-

The possible reason is: the equal sign (=),
Wildcard mean "like,,,," is not accurate, should use the like, can't use said strict equal sign, try this:

Select count (*) from the user where the username LIKE '% % ss'

Hello, I have known the problem is the issue of the equal sign, but now I had a similar problem, and I in the data table with a select Count (*) from the user where the user. The sex=1 and the user. The username like '% % xiao Ming this query query to get a value of 3, then I do a test with mybatis got a null;
This is & lt; Select id="findCount parameterType=" User_UserCustom_vo "resultType"="userCustom & gt;"
Select Count (*) from the user where the user. The sex=# {userCustom. Sex} and the user. The username like '% % ${userCustom. Username}
The query set into a value of 1 and xiao Ming, why I can get the value in data table query, but in mybatis query to null
This is the method of the test
@ Test
Public void testFindCount () throws the Exception
{
SqlSession session.=sqlSessionFactory openSession ();
UserMapper UserMapper=session. GetMapper (UserMapper. Class);
UserCustom UserCustom=new UserCustom ();
UserCustom. SetSex (" 1 ");
UserCustom. SetUsername (" Ming ");
User_UserCustom_vo User_UserCustom_vo=new User_UserCustom_vo ();
User_UserCustom_vo. SetUserCustom (userCustom);
Int I=userMapper. FindCount (user_UserCustom_vo);
System. Err. Println (I);
}
This is User_UserCustom_vo class
Public class User_UserCustom_vo {
Private List The ids.


Public List GetIds () {
Return the ids;
}

Public void setIds (List Ids) {
Enclosing the ids=ids;
}

Private UserCustom UserCustom;

Public UserCustom getUserCustom () {
Return userCustom;
}

Public void setUserCustom (UserCustom UserCustom) {
Enclosing userCustom=userCustom;
}

}


This is the console information: DEBUG [main] - Created connection 1891254926.
The DEBUG [main] - Setting the autocommit to false on JDBC Connection [. Com. Mysql. JDBC Connection @ 70 ba428e]
The DEBUG [main] -==& gt; Preparing: select Count (*) from the user where the user. The sex=? And the user. The username like '% % xiaoming'
The DEBUG [main] -==& gt; The Parameters: 1 (String)
The DEBUG [main] - & lt;==Total: 1
Null

CodePudding user response:

LIKE

CodePudding user response:

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related