Reputation: 1965
I think this is more an SQL related question than a WP related question :::
$result = $wpdb->get_results( " SELECT *
from wp_ngg_gallery, wp_ngg_pictures
where wp_ngg_pictures.galleryid = wp_ngg_gallery.gid
and wp_ngg_gallery.gid = 10
order by wp_ngg_pictures.imagedate
DESC " );
Above is a query that works fine if I'm only getting data from Gallery ID = 10 a single gallery id ( eg. 10 in example ) ::: I want to retrieve data from more than one Gallery ID how could I achieve this ( eg. 10,8,4 ) :::
Upvotes: 0
Views: 312
Reputation: 263733
use IN
wp_ngg_gallery.gid IN (10,8,4 )
full query using ANSI SQL-92
syntax
SELECT *
FROM wp_ngg_gallery
INNER JOIN wp_ngg_pictures
ON wp_ngg_pictures.galleryid = wp_ngg_gallery.gid
WHERE wp_ngg_gallery.gid IN (10,8,4)
ORDER BY wp_ngg_pictures.imagedate DESC
Upvotes: 1