MySQL help needed - Charity!

Author
Discussion

john_p

7,073 posts

251 months

Friday 10th September 2004
quotequote all
BliarOut said:
I am getting the hang of this

OK, to do what I wanted above, I will need to extract and count all the RRC values from the proc table...

So I can use

SELECT COUNT(*) RRCode FROM proc WHERE RRC LIKE 'TA5'

That tells me there are three records in the proc table with the value TA5

That doesn't mean a lot, as we don't know what TA5 really is.

So.... I would imagine I create a table RRCValues which would be

RRCID contains TA1 TA2 etc

RRCDescription A textual description of the RRC Code.

Now, how do I ammend the above statement to link the text from RRCValues table to the proc table?


select count(*),RRCDescription from RRCode,RRCValues where RRCValues.RRCID=RRCode.RRC and RRCode.RRC like 'TA5%'

for example

BliarOut

Original Poster:

72,857 posts

240 months

Friday 10th September 2004
quotequote all
Thank you very much... Slowly but surely, it's taking shape!

BliarOut

Original Poster:

72,857 posts

240 months

Saturday 11th September 2004
quotequote all
Next

I want to count the occurrences of a value in proc.rrc. There are 56 possible codes. The query I have kinda does what I want, but needs refining. It counts, but (correctly I assume) ignores null values. I would like to ammend what I have to count nulls as zeros AND then save that value so I can display it in a web page. Does anyone know how I could modify the following?

SELECT RRC, COUNT( * )
FROM proc
WHERE RRC = 'TA1'
OR RRC = 'TA2'
OR RRC = 'TA3'
OR RRC = 'TA4'
OR RRC = 'TA5'
OR RRC = 'TA6'
OR RRC = 'TA7'
OR RRC = 'TA8'
OR RRC = 'TA9'
OR RRC = 'TA10'
OR RRC = 'TA11'
OR RRC = 'TA12'
OR RRC = 'TA13'
OR RRC = 'TA14'
OR RRC = 'TC1'
OR RRC = 'TC2'
OR RRC = 'TC3'
OR RRC = 'TC4'
OR RRC = 'TC5'
OR RRC = 'TC6'
OR RRC = 'TC7'
OR RRC = 'TC8'
OR RRC = 'TC9'
OR RRC = 'TC10'
OR RRC = 'TC11'
OR RRC = 'TC12'
OR RRC = 'TC13'
OR RRC = 'TC14'
OR RRC = 'OA1'
OR RRC = 'OA2'
OR RRC = 'OA3'
OR RRC = 'OA4'
OR RRC = 'OA5'
OR RRC = 'OA6'
OR RRC = 'OA7'
OR RRC = 'OA8'
OR RRC = 'OA9'
OR RRC = 'OA10'
OR RRC = 'OA11'
OR RRC = 'OA12'
OR RRC = 'OA13'
OR RRC = 'OA14'
OR RRC = 'OC1'
OR RRC = 'OC2'
OR RRC = 'OC3'
OR RRC = 'OC4'
OR RRC = 'OC5'
OR RRC = 'OC6'
OR RRC = 'OC7'
OR RRC = 'OC8'
OR RRC = 'OC9'
OR RRC = 'OC10'
OR RRC = 'OC11'
OR RRC = 'OC12'
OR RRC = 'OC13'
OR RRC = 'OC14'
GROUP BY rrc LIMIT 0 , 58