Hi Folks,
I wonder if sombody could be kind enough to help me with the following three blocks of code?
I've loaded EasyPHP and got the shell of my little system working.
The first block of code works but the syntax of the second two don't.
Are there any really obvious mistakes that I've overlooked ?
In block two I'm simply reading a field from a table and using inputted Gender but although the data is OK the programme is falling thru' to the 'N/A'. Is there something obvious with the 'When/And' clause that I'm missing?
In block three it's simple 'When' clause but I need to concatenate the results. Again anything obviously wrong about the '&' statement ?
I'd really appreciate any pointers, NOT least a pointer to the best PHP SQL Programmers' Guide online or printed.
Thanks.
HAMISH.
BLOCK I:-
SELECT CASE WHEN SUBSTRING(`data`.`t`, 1, 2) = 'BS' THEN 'Inspirational Doer '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'UV' THEN 'Pratical Planner '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'HF' THEN 'Theorising Discusser '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'DO' THEN 'Emotive Doer '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'MF' THEN 'Inspirational Planner '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'WJ' THEN 'Practical Discusser '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'MJ' THEN 'Theorising Doer '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'TD' THEN 'Emotive Planner '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'TH' THEN 'Inspirational Discusser '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'DQ' THEN 'Practical Doer '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'BR' THEN 'Theorising Planner '
WHEN SUBSTRING(`data`.`t`, 1, 2) = 'RK' THEN 'Emotive Discusser '
ELSE 'N/A' END as output
- Show quoted text -
BLOCK II:-
SELECT CASE WHEN SUBSTRING(`data`.`d`, 1, 4) = 'WJOU' And GENDER = 'M' THEN 'Contemplative '
WHEN SUBSTRING(`data`.`d`, 1, 4) = 'OJOU' And GENDER = 'M' THEN 'Neither especially Contemplative nor especially Outgoing '
WHEN SUBSTRING(`data`.`d`, 1, 4) = 'WFYU' And GENDER = 'M' THEN 'Very Outgoing '
WHEN SUBSTRING(`data`.`d`, 1, 4) = 'OFYU' And GENDER = 'M' THEN 'Outgoing '
WHEN SUBSTRING(`data`.`d`, 1, 4) = 'WJOU' And GENDER = 'F' THEN 'Very Contemplative '
WHEN SUBSTRING(`data`.`d`, 1, 4) = 'OJOU' And GENDER = 'F' THEN 'Contemplative '
WHEN SUBSTRING(`data`.`d`, 1, 4) = 'WFYU' And GENDER = 'F' THEN 'Neither especially Contemplative nor especially Outgoing '
WHEN SUBSTRING(`data`.`d`, 1, 4) = 'OFYU' And GENDER = 'F' THEN 'Outgoing '
ELSE 'N/A' END as output
- Show quoted text -
BLOCK III:-
SELECT CASE WHEN SUBSTRING(`data`.`m`, 1, 2) = "BM" THEN OVERALL_BFMETHOD= "All Methods " & OVERALL_BFMETHOD
WHEN SUBSTRING(`data`.`m`, 1, 2) = "DB" THEN OVERALL_BFMETHOD= "Doer " & OVERALL_BFMETHOD
WHEN SUBSTRING(`data`.`m`, 1, 2) = "GY" THEN OVERALL_BFMETHOD= "Planner " & OVERALL_BFMETHOD
WHEN SUBSTRING(`data`.`m`, 1, 2) = "NV" THEN OVERALL_BFMETHOD= "Discusser " & OVERALL_BFMETHOD
WHEN SUBSTRING(`data`.`m`, 1, 2) = "DB" THEN OVERALL_BFMETHOD= "Doer " & OVERALL_BFMETHOD
WHEN SUBSTRING(`data`.`m`, 1, 2) = "GY" THEN OVERALL_BFMETHOD= "Planner " & OVERALL_BFMETHOD
WHEN SUBSTRING(`data`.`m`, 1, 2) = "NV" THEN OVERALL_BFMETHOD= "Discusser " & OVERALL_BFMETHOD
ELSE 'N/A' END OVERALL_BFMETHOD as output
- Show quoted text -