Skip navigation links

MySQL Forums :: Views :: if select does not work in view


Advanced Search

if select does not work in view
Posted by: Denis Kochlyak ()
Date: May 29, 2012 04:03AM

Hi, I am new in mysql and i have a problem to display data in a view, but when I execute my querry without create view, the result is correct. It is only when the view is created the coloumn in question is displaying zeros. My code is the following:

select`p`.`Nom` AS `nom`,
`p`.`Prenom` AS `prenom`, `c`.`Anne` AS `anne`,
`c`.`Personnes_id` AS `Personnes_id`,
`c`.`Date_Debut_Conge` AS `Date_Debut_Conge`,
`c`.`Date_Fin_Conge` AS `Date_Fin_Conge`,
`c`.`DemiJourneD` AS `DemiJourneD`,
`c`.`DemiJourneF` AS `DemiJourneF`,
`c`.`Type_Absence` AS `Type_absence`,
`c`.`Notes` AS `Notes`,
(select if (`c`.`Type_Absence`='congé',((select count(`congett`.`calendrier`.`WeekEnd`) from `congett`.`calendrier`
where ((`congett`.`calendrier`.`Date` between `c`.`Date_Debut_Conge` and `c`.`Date_Fin_Conge`)
and (`congett`.`calendrier`.`WeekEnd` <> 1) and (`congett`.`calendrier`.`CongeLULU` <> 1) and
(`congett`.`calendrier`.`AutreConge` <> 1))) - `c`.`DemiJourneD` - `c`.`DemiJourneF` +
`c`.`CongesDejaPris` ),0)) AS `CongePris`,
((select count(`congett`.`calendrier`.`WeekEnd`) from `congett`.`calendrier` where
(`congett`.`calendrier`.`Date` between `c`.`Date_Debut_Conge` and `c`.`Date_Fin_Conge`))
- `c`.`DemiJourneD` - `c`.`DemiJourneF`) AS `Quantite`
from Personnes p join conges_utilises c on p.id= c.`Personnes_id`

Obviusly the issue is on the "select if" level, because the column is displaying "0" in the view.
My sevrer version is 5.5.23



Edited 1 time(s). Last edit at 05/29/2012 04:05AM by Denis Kochlyak.

Options: ReplyQuote


Subject Views Written By Posted
if select does not work in view 2024 Denis Kochlyak 05/29/2012 04:03AM
Re: if select does not work in view 869 Denis Kochlyak 05/30/2012 01:29AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.