Hi everybody,

I'm new to MySQL and have got the following code that works with Oracle
SQL... After looking at the documentation I realised that DECODE seems to be
reserved for encryption... any idea of how this would work with MySQL? Here
is the code:

The tables are as follows
        table                                            table
table
CUSTOMER                   CUSTOMER_SKILLS     SKILL
CUSTOMER_ID (p)       CUSTOMER_ID(f)           SKILL_ID(p)
CUSTOMER_NAME     SKILL_ID          (f)           SKILL_DESC

(p) Primary Key
(f) Foreign Key

The idea is to select the customer(s) that have 'n' skill(s) and return the
customer name and skill(s) description. The skills are know from the user
input.

SELECT
    DECODE (A.SKILLS_ID, B.SKILLS_ID, D.CUSTOMER_NAME, NULL) "Customer
Name", A.SKILL_DESC "Skill Title"
 FROM   CUSTOMER_DETAILS D, CUSTOMER_SKILLS C, SKILLS B, SKILLS A

 WHERE C.SKILLS_ID  = A.SKILLS_ID
 AND D.CUSTOMER_ID  = C.CUSTOMER_ID
 AND A.SKILLS_ID IN (1,3,5)

 AND    B.SKILLS_ID    = (SELECT MIN(A.SKILLS_ID)
                                             FROM   CUSTOMER_SKILLS A
                                             WHERE  A.CUSTOMER_ID =
D.CUSTOMER_ID
                                             AND A.SKILLS_ID IN  (1,3,5) )
 ORDER BY D.CUSTOMER_NAME, 2;

> Thanks in advance
> Heki
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
>


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to