nynw.net
当前位置:首页 >> mysql语句查询问题 >>

mysql语句查询问题

何不考虑用Mysql自带的IF 语句. 你这句很好理解. $p=18; $sql = "select * from user where if(num2>0,num

D是做什么的? select * from A where A.C not in (select B.C from B )

CREATE table a ( id INT PRIMARY KEY, `date` DATE, flag INT);INSERT INTO a VALUES(1, '2013-06-1', 1);INSERT INTO a VALUES(2, '2013-06-2', 1);INSERT INTO a VALUES(3, '2013-06-3', 1);INSERT INTO a VALUES(4, '2013-06-4', 0);INSERT ...

$sql="SELECT * FROM user_list WHERE name = '$name'"; 单引号不要乱打 还有如果检测结果的话,不要用echo用print_r()除了资源类型,基本都能给你输出 echo语句输出某些类型时是一个空值

少使用一个函数: $sql = "select * from aboutus where abid = '1'";$result = mysql_query($sql);echo mysql_error();//如果数据库语句有错,这里会输出echo "";while($re = mysql_fetch_array($result)){ print_r($re); }

select a.studentId,a.name,a.sex,c.cid,b.cname,c.score into TableA from Student a, Course b, Grade c where a.studentId=c.studentId and c.cid=b.cid select a.studentId,a.name,a.sex, sum(case cname when "语文" then score else 0 end...

select count(*) from information_schema.COLUMNS where TABLE_SCHEMA='test' and table_name='ceshi' 'test' 那个是库名,你替换一下 'ceshi'那个是表名,你也替换你想查找的表名

假设表为 t_1有两列为 col_1,col_2 查询条件v_col_1,v_col_2不知道有没有值 SELECT * FROM t_1 WHERE col_1 = (CASE WHEN v_col_1 IS NULL THEN col_1 ELSE v_col_1 END) AND col_2 = (CASE WHEN v_col_2 IS NULL THEN col_2 ELSE v_col_2 END);

标准的方法是使用UNION联合或者CASE,我认为CASE最好,联合的结果被混淆了,我写一个CASE的例子你试试看: select sum(case when `id1`=1 and `check`='b' then 1 else 0 end) cnt1, sum(case when `id2`=0 and `check`='b' then 1 else 0 end) ...

pars是什么内容,你的数据源是不是oracle的?

网站首页 | 网站地图
All rights reserved Powered by www.nynw.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com