Search
 
SCRIPT & CODE EXAMPLE
 

SQL

get last 3 years data in mysql

<?php  
$x = 1;
$tahun = 2022;
$data = array();
 
while($x <= 3) {

  array_push($data,($tahun));
  $tahun = $tahun-1;
  $x++;
} 

$hasil = implode(',',$data);
var_dump($hasil);

 $sql = "SELECT count(*) nilai FROM {$ref_table} WHERE emp_id = '{$emp_id}' AND flag_del = 'N'
            AND YEAR(begin_date) IN ($hasil)";


?>  
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql page segment 
Sql :: alter server set options dbserver oracle fdw 
Sql :: decalre table in sql 
Sql :: add id column to temp table insert 
Sql :: sql change date time from SGT to GMT 
Sql :: psql check if sql script is valid 
Sql :: database traccar 
Sql :: ltrim in sql 
Sql :: Sql select by content lenght 
Sql :: stratified sampling sql 
Sql :: sql statement checker corrector 
Sql :: C# get column name of sqlreader 
Sql :: sql query use select name inside where clause 
Sql :: grouping function in mysql 
Sql :: meaning of localhost in mysql 
Sql :: do you know sql 
Sql :: oracle rolling back 
Sql :: sql save select into list 
Sql :: pl sql constraint user function 
Sql :: postgres regex word boundary 
Sql :: Mysql Install Ubuntu with native password 
Sql :: how to reset mysql table auto_increment 
Sql :: can you create views in dbbrowser 
Sql :: mysql BEFORE UPDATE INSERT 
Sql :: ORA-13717 
Sql :: mod function example 
Sql :: how to drop mili second in sql 
Sql :: mysqli count down 
Sql :: sql alchemy escape ; in insert statement 
Sql :: oracle last user logon 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =