By exiled_hammer on
Hi,
I am developing a new site which is pushing the boundaries of my SQL knowledge.
I am using the CCK module and I am trying to get some of information from one content type to display on another. This statement retrieves the information that I require what I would like to know is if there is a better way to write this statement out.:
SELECT `content_field_promote_home`.*, `content_field_thumbnail`.*, `node`.*, `content_field_qualityterm`.*, `content_field_qualityterm`.`nid`, `content_type_apartments`.`nid`,`url_alias`.*,`files`.*,`term_data`.* From `content_field_qualityterm`, `content_field_promote_home`, `content_field_thumbnail`, `node`, `content_type_apartments`,`url_alias`,`files`,`term_data` WHERE ((`content_field_promote_home`.`field_promote_home_value` ='yes') AND (`node`.`nid` =`content_field_promote_home`.`nid`) AND (`content_field_thumbnail`.`nid` =`content_field_promote_home`.`nid`) AND (`content_field_qualityterm`.`nid` =`content_field_promote_home`.`nid`) AND (`content_type_apartments`.`nid` =`content_field_promote_home`.`nid`) AND (`url_alias`.`src`= CONCAT("node/", `content_field_promote_home`.`nid`) AND (`files`.`fid`= `content_field_thumbnail`.`field_thumbnail_fid`) AND (`term_data`.`tid`=`content_type_apartments`.`field_sleepsmax_value`) ))
All suggestions appreciated.
John
Comments
You'll want the JOIN
You'll want the JOIN statement. http://dev.mysql.com/doc/refman/5.0/en/join.html - there are loads of tutorials on how to use it on the web.