查询数据库中所有表名 select table_name from information_schema.tables where table_schema='csdb' and table_type='base table'; 查询指定数据库中指定表的所有字段名 select column_name from information_schema.columns where table_schema='csdb' and table_name='users';
mysql使用sql查询表名的两种方法: 1.show tables; 2.SELECT TABLE_NAME,TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=’dbname';–dbname为mysql的数据库名称 查询指定数据库中指定表的所有字段名 select column_name from information_schema.columns where table_schema=’YOURDATABASENAM
SELECT * FROM Master..SysDatabases ORDER BY Name SELECT Name,* FROM Master..SysDatabases where Name='TestDB' SELECT COLUMN_NAME,DATA_TYPE FROM INFORMATION_SCHEMA.columns WHERE TABLE_CATALOG like '%TestDB%' SELECT * FROM INFORMATION_SCHEMA.columns SEL
太久没有用SQL语句都有些忘记了,今天工作中遇到了那就尝试记录一下吧 需求是这样的:想查询同一个字段下,两条指定了不同内容,的其他的值 主要是要想到用where......in 语句如下:select * from jac_motorcade_vehicle where vin in ('VSN00001888888888','ZH201807090001002','ZHT00002000020026')
代码如下: $conn = new mysqli('localhost', 'root', '', 'excel');$sql = "select 中信一级行业 from excel group by 中信一级行业 order by convert(中信一级行业 USING gbk) COLLATE gbk_chinese_ci";//按中文排序$query = $conn->query($sql);$firstClass = array();//一类行业总集$result =
首先我们建立一张带有逗号分隔的字符串. CREATE TABLE test(id int(6) NOT NULL AUTO_INCREMENT,PRIMARY KEY (id),pname VARCHAR(20) NOT NULL,pnum VARCHAR(50) NOT NULL); 然后插入带有逗号分隔的测试数据 INSERT INTO test(pname,pnum) VALUES('产品1','1,2,4'); INSERT INTO test(pname,pnum) VALUES('产
select gid, username from users where FIND_IN_SET(8,gid); //查询gid里含有数字8的记录,gid是varchar ,数据格式:"1,12,8,18,5" select gid, username from users where !FIND_IN_SET(8,gid); //查询gid里不含有数字8的记录,gid是varchar ,数据格式:"1,12,8,18,5"
1.查询重复值: select code,count(*) as count from hospital group by code having count>1; 该语句查询code重复值大于1的记录 2.删除重复: DELETE FROM hospital WHERE id NOT IN (SELECT dt.minno FROM (SELECT MIN(id) AS minno FROM hospital GROUP BY code) dt); 该语句保留id最小的记录,其余code重复的
找第一层: SELECT * FROM tourists WHERE json_data->'$.weixinOpenId' = '299485886686868' 或者 SELECT * FROM devices WHERE JSON_EXTRACT(json_data, "$.lcswAccessToken") = '33e5028835bf4d478ed5cd8f8a618ea5' 找多层: SELECT * FROM devices WHERE json_extract(