引入,导出表
右键表
获得表
遇到关键词的用’“’分割
单个表单个列查询
查询登录方式是微信的用户(字段:from)
SELECT nickname,`from` from y_member WHERE `from` = 'weixin';
查询不是”年会员”的用户(字段:groupid)
SELECT userid,groupid from y_member WHERE groupid!=3;
查询是年会员的用户,显示字段,userid,nickname,from,groupid(重命名为yearnum)
SELECT userid,nickname,`from`,groupid yearnum from y_member WHERE groupid= 3;
查询余额在50-100之间的用户(字段:amount)
SELECT userid,amount from y_member WHERE amount BETWEEN 50 and 100;
查询地址是合肥和芜湖的用户(字段:areaid)
SELECT nickname,areaid from y_member WHERE areaid =1 OR areaid = 2;
查询手机号码是153开头的用户(mobile)
SELECT nickname,mobile FROM y_member WHERE mobile LIKE '153%';
查询昵称带“燕”“婷”“乐”的用户(字段:nickname)
SELECT userid,nickname from y_member WHERE nickname REGEXP '[燕婷乐]';
查询信息,比较余额和积分中的最小值。(字段:amount,point)
SELECT amount,point,LEAST(amount,point) newLeast FROM y_member ;
查询合肥地区的用户,并让登录次数都加上100。(字段:areaid,loginnum)
SELECT nickname,loginnum,(loginnum+100) newLogin FROM y_member WHERE areaid = 1
单个表多个条件查询
查询登录次数大于50的,并且地址是合肥的用户(字段,loginnum,areaid);
SELECT loginnum,areaid FROM y_member WHERE loginnum>50 AND areaid = 1;
查询会员组是“年会员”或者 余额大于60的用户(字段,groupid,amount);
SELECT groupid,amount from y_member WHERE groupid =3 OR amount>60;
查询合肥地区,余额大于60 或者积分大于5的用户(字段,areaid,amount,point)
SELECT areaid,amount FROM y_member WHERE areaid>60 or amount>5;
查询积分和余额相等的用户。
SELECT * FROM y_member WHERE point = amount;
查询合肥地区余额是 60,40,50的用户,或者积分是,4,5,6的用户
SELECT amount,point FROM y_member WHERE amount in(60,40,50) OR point in(4,5,6) ORDER BY amount DESC;
查询昵称包含“丽”,地址是合肥的用户,只显示列userid,nickname,areaid。
SELECT userid,nickname,areaid from y_member WHERE nickname REGEXP '[丽]' and areaid = 1;
查询芜湖和马鞍山地区登录次数大于20次的用户,并按照余额降序排列。
SELECT amount,areaid,loginnum from y_member WHERE areaid in(1,3) AND loginnum>20 ORDER BY amount DESC;
查找马鞍山积分大于10的用户, 已知一页显示10条记录,查询第三页的数据。
SELECT areaid,point FROM y_member WHERE areaid=3 and point>3 LIMIT 20,10
© 版权声明
文章版权归作者所有,未经允许请勿转载,侵权请联系 admin@trc20.tw 删除。
THE END