【发布时间】:2020-11-29 00:43:48
【问题描述】:
所以.. 我懂一点编程,但我的技能有限。今天,我试图进行一个简单的查询,以便在我选择的日期之间找到在我目前工作的医院工作的健康人员。
我想要 4 个输入日期,例如
它是西班牙语,所以这里是翻译:
日期输入是“过滤器”
Started working >= to this date
Started working <= to this date
Quit the job >= to this date
Quit the job <= to this date
而2选输入的是个人拥有的职称和专业程度。 (我需要两者都可以为空的选项)
所以我可以解决这个问题,为每个可能的情况创建一个 SQL 查询,如下所示:
if ($titulo == '0' && $especialidad == '0' && $date1!=null && $date2==null &&
$bdesde==null && $bhasta==null){
$sql_query= "select * from personal where starting_date >= '$date1'" }
elseif ( ... and so on
数据库是 MySQL。
但我想知道是否有办法用更少的代码做我想做的事。
【问题讨论】:
标签: php html mysql sql where-clause