I want to check the value of two columns and create a third one based on those values. Here's my view deff:
CREATE VIEW `vw_movies` AS
select
`tbl_movies`.`id` AS `id`,
`tbl_movies`.`vendor_id` AS `vendor_id`,
`tbl_vendors`.`title` AS `title_vendor`,
`tbl_movies`.`title` AS `title`,
`tbl_movies`.`year` AS `year`,
`tbl_movies`.`synopsis` AS `synopsis`,
`tbl_movies`.`plot` AS `plot`,
`tbl_movies`.`director` AS `director`,
`tbl_movies`.`stars` AS `stars`,
`tbl_movies`.`language` AS `language`,
`tbl_movies`.`rating_id` AS `rating_id`,
`tbl_ratings`.`title` AS `rating`,
`tbl_movies`.`img_path` AS `img_path`,
`tbl_movies`.`trailer_path` AS `trailer_path`,
`tbl_movies`.`file_path` AS `file_path`,
`tbl_movies`.`is_active` AS `is_active`,
(case `tbl_movies`.`is_active`
when 0 then 'No'
when 1 then 'Yes'
end) AS `is_active_text`,
`tbl_movies`.`is_confirmed` AS `is_confirmed`,
(case `tbl_movies`.`is_confirmed`
when 0 then 'No'
when 1 then 'Yes'
end) AS `is_confirmed_text`,
`tbl_movies`.`created` AS `created`,
`tbl_movies`.`modified` AS `modified`
from
((`tbl_movies`
join `tbl_vendors` ON ((`tbl_movies`.`vendor_id` = `tbl_vendors`.`id`)))
join `tbl_ratings` ON ((`tbl_movies`.`rating_id` = `tbl_ratings`.`id`)))
What I want to check is the value of is_confirmed and is_confirmed:
- if is_confirmed == 1 && is_confirmed == 1 then "Live"
- else if is_confirmed == 0 && is_confirmed == 0 then "Initial"
- else if is_confirmed == 1 && is_confirmed == 0 then "In-active/Dead Link"
How can I implement such if-select statement in MySQL?
casestatements. That is how you would implement such logic. Don't you understand how the code you posted actually works?