问题描述 求sql语句中带有条件的查询 我现在有一张users表,有字段uid,uname,address,phone1,phone2,phone3: 我想在这张表中这样查: 主要查phone1,但是如果有一条数据的phone1位空的话,就查phone2,如果phone1,phone2都为空就查phone3,这样的SQL语句要怎么写呢,求大神帮忙解答???? 解决方案 select case when phone1 is null then ( case when phone2 is null
问题描述 mysql数据库sql语句优化,求大神!!!! SELECT DISTINCT uid, level,username,ansnum FROM test WHERE level=100 GROUP BY uid ORDER BY ansnum DESC LIMIT 12; uid.ansnum均已建索引,主要是GROUP BY uid导致特别慢,如何提速??? 解决方案 MySQL数据库SQL语句优化原则 解决方案二: 根据你的查询需求,没有特别好的优化办法.注意group by 和o
问题描述 sql语句出错,求大神帮忙解答 CREATE PROCEDURE test() BEGIN DECLARE fid int; DECLARE days int DEFAULT 1; DECLARE s int default 0; DECLARE company_code VARCHAR; DECLARE cursor_company CURSOR FOR SELECT company FROM test WHERE status = 3; DECLARE CONTINUE HANDL