Bug #20663 COntrol Flow Conditional Ckecking for IF not sufficient
Submitted: 23 Jun 2006 14:29 Modified: 4 Sep 2007 6:01
Reporter: Maheshkumaar Umale Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version:5.x OS:Linux (Linux)
Assigned to: CPU Architecture:Any

[23 Jun 2006 14:29] Maheshkumaar Umale
Description:
Is there any way solve this problem in MySQL :
Suppose I have a table 
+---------------+--------------+------+-----+---------+-------+ | Field         | Type         | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ 
| MemberId      | int(11)      | NO   | MUL |         |       | 
| GroupId       | int(11)      | YES  | MUL | NULL    |       |
| LastName      | varchar(30)  | YES  |     | NULL    |       |
| FirstName     | varchar(30)  | YES  |     | NULL    |       |
| MiddleInitial | char(1)      | YES  |     | NULL    |       |
| WorkPhone     | varchar(30)  | YES  |     | NULL    |       |
| Home          | varchar(30)  | YES  |     | NULL    |       |
| Mobile        | varchar(30)  | YES  |     | NULL    |       |
| Email1        | varchar(40)  | YES  |     | NULL    |       |
| Email2        | varchar(40)  | YES  |     | NULL    |       |
| InvitedBy     | int(11)      | YES  |     | NULL    |       |
| Interests     | varchar(100) | YES  | MUL | NULL    |       |
| BirthDate     | date         | YES  |     | NULL    |       |
| BirthCity     | varchar(100) | YES  |     | NULL    |       |
| BirthState    | varchar(100) | YES  |     | NULL    |       |
| BirthCountry  | varchar(100) | YES  |     | NULL    |       |
| Url           | varchar(100) | YES  |     | NULL    |       |
| OtherContact1 | varchar(100) | YES  |     | NULL    |       |
| OtherContact2 | varchar(100) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+
 which contain two rows per Member , one as MemberId , GroupId = 999
and second as MemberId , GroupId = 'actualGroupId' (Let us say 1)
Now The row with 999 GroupId is filled when first time user login. And row with 
GroupId (1) is kept null Now only data which he updates comes in row with GroupId 1 while other row for that member remains unchanged.
Now There are conditions that some of fiels in modified row are still null.
We want query which will return us DataFrom row GroupId = 999 only if row
with GroupId (1) is null .
eg:  consider Data ::
MemberId      | GroupId       | LastName      |FirstName    
----------------------------------------------------------
1                 999            Umale          Mahesh 
1                 1              NULL           Maheshkumar
2                 999            Deshmukh       Shilpa
2                 1              Pedgaonkar     NULL 
3                 999            Godbole        Amit 
3                 1              NULL           NULL 

NOw I should get Output for LastName      FirstName =====> OutPut(MemberId)
                            Umale         Maheshkumar  ===> 1       
                            Umale         Mahesh       ===> NO ROW FOUND
                            Deshmukh     Shilpa        ===> NO ROW FOUND
                            Pedgaonkar   Shilpa        ===> 1
                            Godbole        Amit        ===> 1
What is the way ?? Please help

How to repeat:
Is there any way solve this problem in MySQL :
Suppose I have a table 
+---------------+--------------+------+-----+---------+-------+ | Field         | Type         | Null | Key | Default | Extra | +---------------+--------------+------+-----+---------+-------+ 
| MemberId      | int(11)      | NO   | MUL |         |       | 
| GroupId       | int(11)      | YES  | MUL | NULL    |       |
| LastName      | varchar(30)  | YES  |     | NULL    |       |
| FirstName     | varchar(30)  | YES  |     | NULL    |       |
| MiddleInitial | char(1)      | YES  |     | NULL    |       |
| WorkPhone     | varchar(30)  | YES  |     | NULL    |       |
| Home          | varchar(30)  | YES  |     | NULL    |       |
| Mobile        | varchar(30)  | YES  |     | NULL    |       |
| Email1        | varchar(40)  | YES  |     | NULL    |       |
| Email2        | varchar(40)  | YES  |     | NULL    |       |
| InvitedBy     | int(11)      | YES  |     | NULL    |       |
| Interests     | varchar(100) | YES  | MUL | NULL    |       |
| BirthDate     | date         | YES  |     | NULL    |       |
| BirthCity     | varchar(100) | YES  |     | NULL    |       |
| BirthState    | varchar(100) | YES  |     | NULL    |       |
| BirthCountry  | varchar(100) | YES  |     | NULL    |       |
| Url           | varchar(100) | YES  |     | NULL    |       |
| OtherContact1 | varchar(100) | YES  |     | NULL    |       |
| OtherContact2 | varchar(100) | YES  |     | NULL    |       |
+---------------+--------------+------+-----+---------+-------+
 which contain two rows per Member , one as MemberId , GroupId = 999
and second as MemberId , GroupId = 'actualGroupId' (Let us say 1)
Now The row with 999 GroupId is filled when first time user login. And row with 
GroupId (1) is kept null Now only data which he updates comes in row with GroupId 1 while other row for that member remains unchanged.
Now There are conditions that some of fiels in modified row are still null.
We want query which will return us DataFrom row GroupId = 999 only if row
with GroupId (1) is null .
eg:  consider Data ::
MemberId      | GroupId       | LastName      |FirstName    
----------------------------------------------------------
1                 999            Umale          Mahesh 
1                 1              NULL           Maheshkumar
2                 999            Deshmukh       Shilpa
2                 1              Pedgaonkar     NULL 
3                 999            Godbole        Amit 
3                 1              NULL           NULL 

NOw I should get Output for LastName      FirstName =====> OutPut(MemberId)
                            Umale         Maheshkumar  ===> 1       
                            Umale         Mahesh       ===> NO ROW FOUND
                            Deshmukh     Shilpa        ===> NO ROW FOUND
                            Pedgaonkar   Shilpa        ===> 1
                            Godbole        Amit        ===> 1
What is the way ?? Please help
[4 Sep 2007 6:01] Valeriy Kravchuk
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem is not the result of a bug.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.