永发信息网

mysql数据库怎么加入年龄查询语句?

答案:2  悬赏:0  手机版
解决时间 2021-02-26 06:29
  • 提问者网友:风月客
  • 2021-02-26 03:38
SELECt * FROM `uchome_space` AS `space` LEFT JOIN `uchome_spacefield` AS

`spacefield` on `space`.`uid`=`spacefield`.`uid` WHERe

`space`.`credit`>'111' AND `space`.`credit`<'222' AND

`spacefield`.`sex`='2' AND `space`.`groupid` in ('1','2','3') ORDER BY

`space`.`lastlogin` DESC, `space`.`friendnum` ASC, `space`.`dateline` ASC

怎么把查询年龄的语句和上面的语句整合在一起?
得到的年龄值怎么调用输出?现在用 $value[sex]输出性别数据。
出生年份字段是 birthyear,包含在语句中的uchome_spacefield表中

非常感谢!
最佳答案
  • 五星知识达人网友:想偏头吻你
  • 2021-02-26 04:27
SELECt
------------------------------是不是这个意思
substring(now(),1,4) - spacefield.birthyear as age
------------------------------
FROM `uchome_space` AS `space` LEFT JOIN `uchome_spacefield` AS

`spacefield` on `space`.`uid`=`spacefield`.`uid` WHERe

`space`.`credit`>'111' AND `space`.`credit`<'222' AND

`spacefield`.`sex`='2' AND `space`.`groupid` in ('1','2','3') ORDER BY

`space`.`lastlogin` DESC, `space`.`friendnum` ASC, `space`.`dateline` ASC

输出用 $value[age]
全部回答
  • 1楼网友:渊鱼
  • 2021-02-26 04:35

sql = " select * from product where name like ? or note like ? or price like ? or amount like ? order by pid limit ? , ? ";

pstmt = conn.preparestatement(sql) ; pstmt.setstring(1,"%"+keyword+"%") ; pstmt.setstring(2,"%"+keyword+"%") ; pstmt.setstring(3,"%"+keyword+"%") ; pstmt.setstring(4,"%"+keyword+"%") ; pstmt.setint(5,(currentpage -1)* linesize) ; pstmt.setint(6,linesize) ;

rs = pstmt.executequery() ;

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯