一、mysql查询是否含有某字段:
mysql数据库查询带有某个字段的所有表名
SELECT * FROM information_schema.columns WHERE column_name='column_name';
oracle数据库查询带有某个字段的所有表名
select column_name,table_name,from user_tab_columns where column_name='column_name';
二、查询数据库是否使用索引 explain
(1)没使用
使用了
三、查询数据库是否含有某表
在某数据库下
select count(*) from information_schema.TABLES t where t.TABLE_SCHEMA ='数据库名' and t.TABLE_NAME ='表名'
在该用户下有多少张表
select count(*) from information_schema.TABLES t where t.TABLE_NAME ='表名'
四、FIND_IN_SET
五,
一条sql语句查询n个表的数据的数据个数
SELECT
count( * ) ,
b.admin,
c.lang
FROM
tp_lang AS a
Left join
(select count(*) admin from tp_admin) as b on 1=1
Left join
(select count(*) lang from tp_lang) as c on 1=1
经典sql
SELECT
a.*, b.attr, c.nameStr
FROM
tp_goods a
LEFT JOIN
(SELECT goods_id, GROUP_CONCAT(attr_item_id) attr FROM tp_goods_attr_link GROUP BY goods_id) as b ON a.id = b.goods_id
left JOIN
(SELECT iid, GROUP_CONCAT(value) nameStr FROM tp_lang_info GROUP BY iid) as c ON a.name = c.iid SEPARATOR \'|..|\'
六,sql排序、
结果
3最后 2倒数第二 1倒数第三
结果