Reputation: 2289
I have this code, which selects content types from database, and then build its view depends on content types.
$q = db_query('SELECT n.nid, n.title, r.body, f.filename
FROM {node} n
INNER JOIN {node_revisions} r ON n.vid = r.vid
INNER JOIN {content_type_brands} p ON p.nid = n.nid
INNER JOIN {files} f ON f.fid = p.field_deyat_pic_fid
WHERE n.type = "brands"');
But it displays every content type, when i need to make this code to show only specific content types. Hod do i do to show only selected content types?
Upvotes: 1
Views: 121
Reputation: 263803
change n
to p
in your WHERE
clause.
SELECT n.nid, n.title, r.body, f.filename
FROM {node} n
INNER JOIN {node_revisions} r
ON n.vid = r.vid
INNER JOIN {content_type_brands} p
ON p.nid = n.nid
INNER JOIN {files} f
ON f.fid = p.field_deyat_pic_fid
// WHERE p.type = 'brands'
WHERE p.type IN ('brand1','brand1','brand1')
Upvotes: 3