找到 4219 篇文章 关于 MySQLi
![Krantik Chavan](https://tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
234 次浏览
检查行是否存在最有效的方法是使用 count(): select count(1) from yourTableName where yourCondition; 让我们先创建一个表: mysql> create table DemoTable ( Id int, FirstName varchar(20) ); 以下是用 insert 命令在表中插入一些记录的查询: mysql> insert into DemoTable values(100, 'Larry'); mysql> insert into DemoTable values(110, 'Sam'); mysql> insert into DemoTable values(120, 'Mike'); mysql> insert into DemoTable values(130, 'Carol'); Query ... 阅读更多
![Arjun Thakur](https://tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
870 次浏览
要启用通用日志,您需要使用 SET 命令。以下是语法: set global general_log=ON; 让我们使用 SHOW 命令检查通用日志状态: mysql> SHOW variables like '%general_log%'; 这将产生以下输出: +------------------+---------------------+ | Variable_name | Value | +------------------+---------------------+ | general_log | OFF | | general_log_file | DESKTOP-QN2RB3H.log | +------------------+---------------------+ 2 rows in set ... 阅读更多
![Chandu yadav](https://tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
1K+ 次浏览
首先,您需要检查主机。主机可以是“localhost”或“%”。检查具有主机权限的用户帐户的存在: mysql> select user, host from MySQL.user; 这将产生以下输出: +------------------+-----------+ | user | host | +------------------+-----------+ | Bob | % | | User2 | % | | mysql.infoschema | % | ... 阅读更多
![Ankith Reddy](https://tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
756 次浏览
要根据出生日期计算年龄,您可以使用以下语法: select timestampdiff(YEAR, yourColumnName, now()) AS anyAliasName from yourTableName; 让我们先创建一个表: mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentDOB datetime ); 使用 insert 命令在表中插入一些记录: mysql> insert into DemoTable(StudentDOB) values('1996-01-12'); mysql> insert into DemoTable(StudentDOB) values('1990-12-31'); mysql> insert into DemoTable(StudentDOB) values('1989-04-01'); mysql> insert into DemoTable(StudentDOB) values('2000-06-17'); Query ... 阅读更多
![George John](https://tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
921 次浏览
要在 MySQL 中计算空值,您可以使用 CASE 语句。让我们先来看一个例子并创建一个表: mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); 使用 insert 命令在表中插入一些记录: mysql> insert into DemoTable(FirstName) values('John'); mysql> insert into DemoTable(FirstName) values(null); mysql> insert into DemoTable(FirstName) values(''); mysql> insert into DemoTable(FirstName) values('Larry'); Query ... 阅读更多
![Krantik Chavan](https://tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
4K+ 次浏览
要在 MySQL 中跳过空白和空值,请使用以下语法: select * from yourTableName where yourColumnName IS NOT NULL AND yourColumnName ''; 让我们先创建一个表: mysql> create table DemoTable (Id int, FirstName varchar(20)); 以下是用 insert 命令在表中插入记录的查询: mysql> insert into DemoTable values(100, 'Larry'); mysql> insert into DemoTable values(101, ''); mysql> insert into DemoTable values(102, 'Chris'); mysql> insert into DemoTable values(103, null); Query ... 阅读更多
![Chandu yadav](https://tutorialspoint.com/assets/profiles/22330/profile/60_142811-1519038104.jpg)
202 次浏览
是的,我们可以在不使用 LIMIT 子句的情况下从表中选择第二大的记录。让我们先来看一个例子并创建一个表: mysql> create table DemoTable ( Number int ); 使用 insert 命令在表中插入记录: mysql> insert into DemoTable values(78); mysql> insert into DemoTable values(67); mysql> insert into DemoTable values(92); mysql> insert into DemoTable values(98); mysql> insert into DemoTable values(88); ... 阅读更多
![Arjun Thakur](https://tutorialspoint.com/assets/profiles/13574/profile/60_74441-1560315595.jpg)
75 次浏览
为此,您可以使用 INFORMATION_SCHEMA.COLUMNS,如下面的语法所示: SELECT * FROM (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME= 'yourTableName') anyAliasName; 让我们先创建一个表: mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(20), StudentLastName varchar(20), StudentAge int ); 以下是将`SHOW COLUMNS`用作有效数据源的查询: mysql> SELECT * FROM (SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME= 'DemoTable')tbl; 这将产生以下输出: +---------------+--------------+-------------+------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+-------------+------------+----------------+---------------------------------+----------------+-----------------------+--------+ | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | ... 阅读更多
![Krantik Chavan](https://tutorialspoint.com/assets/profiles/13545/profile/60_126883-1512724834.jpg)
325 次浏览
您可以使用 MySQL 中的 LEFT() 来显示 MySQL 中整个值中的一些字符。以下是语法: select left(yourColumnName ,200 ) AS anyAliasName from yourTableName; 让我们先创建一个表: mysql> create table DemoTable (Paragraph longtext); 以下是用 insert 命令在表中插入记录的查询: mysql> insert into DemoTable values('Introduction to Java, Introduction to C, Introduction to C++, Introduction to Spring, Introduction to Hibernate, Introduction to Python, Introduction to MySQL, Introduction to MongoDB, Introduction to SQL Server, Introduction to ASP.net, Introduction to JSF'); 以下 ... 阅读更多
![Ankith Reddy](https://tutorialspoint.com/assets/profiles/22328/profile/60_142162-1519038074.jpg)
73 次浏览
是的,您可以使用 SELECT AUTO_INCREMENT 语句找出下一个自动增量值,如下所示:SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA= yourDatabaseName AND TABLE_NAME=yourTableName; 让我们先创建一个表:mysql> create table DemoTable ( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(20), ClientAge int ); Query OK, 0 rows affected (1.33 sec) 使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable(ClientName, ClientAge) values('John', 23); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable(ClientName, ClientAge) values('Carol', 21); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable(ClientName, ClientAge) values('Bob', ... 阅读更多