[MySQL] Contoh Penggunaan If Else di Query MySQL

 

SELECT employees.fullname Fullname, departement.name Departement, jobposition.name Position, overtime.duration, overtimeplan.id,

IF(overtimeplan.id != NULL,    ‘planned’,       ‘not planned’    ) AS isplanned 

FROM `overtime`inner join net_hrd.employees on overtime.employees_id=employees.id

inner join net_hrd.departement on employees.departement_id = departement.id

inner join net_hrd.jobposition on employees.jobposition_id = jobposition.id

LEFT JOIN overtimeplan on overtime.employees_id=overtimeplan.employees_id and overtime.date=overtimeplan.datewhere overtime.date>=’2018-01-01′

 

Referensi :

https://stackoverflow.com/questions/8763310/how-do-write-if-else-statement-in-a-mysql-query

http://www.easysolutionweb.com/mysql-tutorials/how-to-use-if-and-else-in-mysql

2 pemikiran pada “[MySQL] Contoh Penggunaan If Else di Query MySQL

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s