exists

Check if MySQL table exists or not [duplicate]

六眼飞鱼酱① 提交于 2019-11-27 20:22:57
Possible Duplicate: MySQL check if a table exists without throwing an exception I have a dynamic mysql query builder in my project that creates select queries from different tables. I need to check if the current processing table exists or not. Imagine that my tables are table1, table2, and table3. My code is something like this: <?php for($i = 1 ; $i <= 3 ; $i++) { $this_table = 'table'.$i; $query = mysql_query("SELECT * FROM $this_table"); // ... } ?> How can I do this check (Please tell me the simplest way). Updated mysqli version: if ($result = $mysqli->query("SHOW TABLES LIKE '".$table."'

【MySQL】查询语句优化

偶尔善良 提交于 2019-11-27 20:07:06
原文: http://blog.gqylpy.com/gqy/389 " MySQL的性能优化包罗甚广:索引优化、查询优化、查询缓存、服务器设置优化、操作系统及硬件优化、应用层优化(web服务器、缓存)等等。本文提到的优化技巧更适用于开发人员,都是从网络上收集和自己整理的,主要是查询语句上面的优化,其它层面的优化技巧在此不做记录。 整理如下 合理创建索引 count 的优化 避免使用不兼容的数据类型 索引字段上进行运算会使索引失效 尽量避免使用 != 、 is null 、 is not null 、 in 、 not in 这样的操作符 尽量使用数字型字段 合理使用 exists 、 not exists 子句 能够用 between 的就不要用 in 能够用 distinct 的就不要用 group by 尽量不要使用 select info 语句,它会导致表锁,阻止其它用户访问该表 必要时强制查询优化器使用某个索引 消除对大型表行数据的顺序存取 程序中如果需要一次性对同一个表插入多条数据,应写成一条语句 查询的开销指标 执行时间 检查的行数 返回的行数 建立索引的几个准则 合理的建立索引能够加快数据读取效率,不合理的建立索引反而会拖慢数据的响应速度。 索引越多,更新数据的速度越慢。 尽量在采用 MyISAM 作为存储引擎的时候使用索引(因为MySQL以Btree存储索引)

多表查询

限于喜欢 提交于 2019-11-27 19:06:15
原文章: https://www.cnblogs.com/majj/p/9174404.html 准备工作:准备两张表,部门表(department)、员工表(employee) create table department( id int, name varchar(20) ); create table employee( id int primary key auto_increment, name varchar(20), sex enum('male','female') not null default 'male', age int, dep_id int ); #插入数据 insert into department values (200,'技术'), (201,'人力资源'), (202,'销售'), (203,'运营'); insert into employee(name,sex,age,dep_id) values ('egon','male',18,200), ('alex','female',48,201), ('wupeiqi','male',38,201), ('yuanhao','female',28,202), ('nvshen','male',18,200), ('xiaomage','female',18,204) ; #

How do I check for the existence of an external file with XSL?

自闭症网瘾萝莉.ら 提交于 2019-11-27 17:38:24
问题 I've found a lot of examples that reference Java and C for this, but how do I, or can I, check for the existence of an external file with XSL. First, I realize that this is only a snippet, but it's part of a huge stylesheet, so I'm hoping it's enough to show my issue. <!-- Use this template for Received SMSs --> <xsl:template name="ReceivedSMS"> <!-- Set/Declare "SMSname" variable (local, evaluates per instance) --> <xsl:variable name="SMSname"> <xsl:value-of select=" following-sibling::Name"

How to check if a file exists on a server using c# and the WebClient class

元气小坏坏 提交于 2019-11-27 17:35:33
问题 In my application I use the WebClient class to download files from a Webserver by simply calling the DownloadFile method. Now I need to check whether a certain file exists prior to downloading it (or in case I just want to make sure that it exists). I've got two questions with that: What is the best way to check whether a file exists on a server without transfering to much data across the wire? (It's quite a huge number of files I need to check) Is there a way to get the size of a given

how to prevent “directory already exists error” in a makefile when using mkdir

▼魔方 西西 提交于 2019-11-27 16:54:21
I need to generate a directory in my makefile and I would like to not get the "directory already exists error" over and over even though I can easily ignore it. I mainly use mingw/msys but would like something that works across other shells/systems too. I tried this but it didn't work, any ideas? ifeq (,$(findstring $(OBJDIR),$(wildcard $(OBJDIR) ))) -mkdir $(OBJDIR) endif tchen On UNIX Just use this: mkdir -p $(OBJDIR) The -p option to mkdir prevents the error message if the directory exists. ofavre Looking at the official make documentation , here is a good way to do it: OBJDIR := objdir

Checking whether an item does not exist in another table

喜欢而已 提交于 2019-11-27 15:36:43
问题 My tables are set up something like this: table name: process fields: name, id_string table name: value_seach fields: id_string, value I want to construct a select statement that will display all of the process names (with it's respective id_string) that do not have an entry in value_search. The id_string in the process table can be null , and still have a name, but those need to be excluded if possible. The id_string in value_search can never be null How do I do this? 回答1: In general if you

数据库

痴心易碎 提交于 2019-11-27 15:02:20
1 /* 2 SQLyog v10.2 3 MySQL - 5.5.27 : Database - restrant 4 ********************************************************************* 5 */ 6 7 8 /*!40101 SET NAMES utf8 */; 9 10 /*!40101 SET SQL_MODE=''*/; 11 12 /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 13 /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 14 /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 15 /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 16 CREATE DATABASE /*!32312 IF NOT EXISTS*/`restrant` /*!40100 DEFAULT CHARACTER SET utf8 */; 17

【MySQL】多表查询 -- 2019-08-17 04:09:33

≯℡__Kan透↙ 提交于 2019-11-27 14:28:59
原文: http://blog.gqylpy.com/gqy/252 " 目录 多表链接查询 笛卡尔积 内链接 inner join 外链接之左链接 left join 外链接之右链接 right join 全外链接 符合条件链接查询 子查询 先准备两张表:部门表(department)、员工表(employee) # 部门表create table department( id int primary key auto_increment, name varchar(20) not null ); # 员工表create table employee( id int primary key auto_increment, name varchar(20) not null, sex enum('male', 'female') not null default 'male', age int not null, dep_id int not null ); # 插入数据insert into department values(200, "技术"),(201, "人力资源"),(202, "销售"),(203, "运营"); insert into employee(name, sex, age, dep_id) values('egon', 'male', 18, 200),(

【MySQL】多表查询 -- 2019-08-17 04:02:20

末鹿安然 提交于 2019-11-27 14:28:42
原文: http://blog.gqylpy.com/gqy/252 " 目录 多表链接查询 笛卡尔积 内链接 inner join 外链接之左链接 left join 外链接之右链接 right join 全外链接 符合条件链接查询 子查询 先准备两张表:部门表(department)、员工表(employee) # 部门表create table department( id int primary key auto_increment, name varchar(20) not null ); # 员工表create table employee( id int primary key auto_increment, name varchar(20) not null, sex enum('male', 'female') not null default 'male', age int not null, dep_id int not null ); # 插入数据insert into department values(200, "技术"),(201, "人力资源"),(202, "销售"),(203, "运营"); insert into employee(name, sex, age, dep_id) values('egon', 'male', 18, 200),(