I code much better with drink than after drink.
You never had to use JOIN before? Obviously you are not married. Although marriage tends to be a left join or right join as opposed to a straight join, which allows you to force an order.
http://dev.mysql.com/doc/mysql/en/LEFT_JOIN_optimization.html
On Dec 1, 2004, at 9:02 AM, Tristan.Pretty@xxxxxxxxxxxxxxxx wrote:
No offence taken!
I've never had to use JOIN before...
and the test was supposed to take an hour.. I didn;t wanna cheat... and it
took me ages to even realise what I was supposed to be doing...
(Plus I@m hungover :-( )
Anyhoo, I'll try what you've suggested... Cheers.. we live, we learn...
Brent Baisley <brent@xxxxxxxxxxxx> 01/12/2004 13:44
To Tristan.Pretty@xxxxxxxxxxxxxxxx cc <php-db@xxxxxxxxxxxxx> Subject Re: Job interview test - I give up...
OK. No offense, but that seems fairly easy.
Here's one possible answer:
select categories.*,count(dv_id) from categories left join dvds on dv_caid=ca_id group by ca_name having ca_name not like 'T%';
On Dec 1, 2004, at 8:13 AM, Tristan.Pretty@xxxxxxxxxxxxxxxx wrote:
I recently saw a job that I thought I'd be good for, so they sent me a test... All good.. but I realised that I couldn't do it.. I got sooo damned close, but could not finish... :-(
Anyhoo, here's the test: http://www.beertastic.co.uk/test_problem.zip
And the test parameters are below If anyone can tell me the answer, I'd appreciate it, then I can de-engineer it, and hopefully learn something. I've already mailed them and said thanks, but I give up ;-)
I my prob was in gettin ga distict list of all DVD categories, from within the final results page...
Hmmm, any takers?
TASK:-
Modify the test.php file (attached) so a list of categories and the
number of DVDs in each category are displayed when the script is called
in a browser. (See resultspage.html for the EXACT output required)
You must complete the getNumDvdsInCategories() function to query the database and return a multidimensional array in the required format.
You may use the PHP and MySQL manuals available online.
RESTRICTIONS:-
You may only make ONE select query to the database.
Do not edit code outside the getNumDvdsInCategories() function. The
results in the table must be in alphabetical order (category name). The
Drama category MUST appear even though there are no DVDs in the
category. Categories beginning with the letter "T" must not be
displayed. Values in the database cannot be hardcoded anywhere in the
script.
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php