Sponsored by NuSphere - PHP Software for PHP Application Developers - On Sale This Week for $100



Go Back   PHP-Editors > Linux, Apache, MySQL > MySQL Help

MySQL Help Post any question relating to MySQL here and hopefully someone can help

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 2004-07-19, 03:22 PM
Junior Member
 
Join Date: Jul 2004
Posts: 1
mconnors
Default

I'm so confused so I thought I'd ask for help- how do i write this statment...

Code:
Select $f.username AS USER, COUNT(*) AS PHOTOS, SUM($i.views) AS VIEWS, SUM($i.downloads) AS DOWN, MAX(UNIX_TIMESTAMP($i.date_added)) AS UPLOAD, $f.user_regdate AS REG, $f.user_posts AS POST FROM $i,$f WHERE $i.author=$f.username GROUP BY USER
so that it will list all $f.username even if there is no corresponding $i.author=$f.username, I've tried a bunch of different ways including

Code:
FROM $f 
LEFT JOIN $i ON $f.username=$i.author
GROUP BY USER
but it keeps generating a million results and keeps crashing the server (ergo I thought I should stop futzin and ask the question)

Any help would be greatly appreciated
admin@morguefile.com
Reply With Quote
  #2 (permalink)  
Old 2004-07-19, 05:12 PM
Xnuiem's Avatar
Senior Member
 
Join Date: May 2004
Location: DFW, Texas
Posts: 1,104
Xnuiem will become famous soon enough
Send a message via Yahoo to Xnuiem
Default

The best way, from a database standpoint is to use reserved ids.

have id 1 be Jane Doe, and make all refs to a user that are 0, actually be on instead. Enforce this with your database and application.

This way, you can use complex queries and then just filter if you need to when the information comes back out of the query.
__________________
I rarely give code examples.
No, I have never used IIS or Windows of any kind as a web server. Get a real OS!
Please don't PM me, I won't respond.
Reply With Quote
Must read Review for Serious PHP Developers


NuSphere PhpED 5.5 : The Staff of php-editors.com recently spent a few days working with NuSphere PhpED 5.5 (a popular PHP IDE) and NuCoder 2.0 (a PHP Encoding Utility), read up on all the details.

Sponsored Links
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 11:11 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
© Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.