Jump to content


Photo

MySQL Query from more tables


  • Please log in to reply
24 replies to this topic

#21 superaktieboy

superaktieboy
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 29 October 2006 - 07:58 PM

oh thx didn't see that one  :P
but now i get another error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE m.id > 0' at line 8


#22 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 29 October 2006 - 08:09 PM

Did you add the "ON" clauses to specify the joins? If so, what does the query look like now?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#23 superaktieboy

superaktieboy
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 30 October 2006 - 09:16 AM

Thx .. it worked, it was without the ON bit .. i added it and it worked :) thx
here is the query for other people
SELECT DISTINCT
    m.*,
    f.*,
    o.*
FROM members AS m
    LEFT JOIN online AS o ON o.userid = m.id 
    LEFT JOIN friends AS f ON f.userid = m.id
WHERE
    m.id > 0


#24 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 30 October 2006 - 05:06 PM

FYI, the distinct is probably unnecessary here, since you're getting back UIDs, which will be unique a.k.a. distinct anyway.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#25 superaktieboy

superaktieboy
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 31 October 2006 - 08:00 AM

oh ok.. i did that




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users