Old 02-05-2007, 12:11   #1 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
help with mysql query

Nevermind. I got it:

SELECT cms_module_feusers_belongs.groupid, cms_module_feusers_properties.data
FROM cms_module_feusers_belongs, cms_module_feusers_properties
WHERE cms_module_feusers_belongs.userid = cms_module_feusers_properties.userid
AND cms_module_feusers_properties.title = 'emailaddress'
AND cms_module_feusers_belongs.groupid = '$groupid'


Last edited by pgo : 02-05-2007 at 12:22.
  Reply With Quote
Old 06-05-2007, 14:49   #2 (permalink)
Paul Freeman
chromophile
 
Join Date: May 2007
Location: Somewhere in Europe
Posts: 7
A tip. Using aliases makes things easier to read... and therefore easier to write and debug

I'd write

SELECT belongs.groupid, properties.data
FROM cms_module_feusers_belongs belongs, cms_module_feusers_properties properties
WHERE belongs.userid = properties.userid
AND properties.title = 'emailaddress'
AND belongs.groupid = '$groupid'

but if you like long names... thats your call.

I write code this way

SELECT b.groupid, p.data
FROM cms_module_feusers_belongs b, cms_module_feusers_properties p
WHERE b.userid = p.userid
AND p.title = 'emailaddress'
AND b.groupid = '$groupid'

arguably this last is a bit cryptic, but its less to type, but easy to think about as b and p are mnemonic. I'm a lazy sod though and that might be why I like it.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8