Somewhat new to SQL queries and I need a little help with my join.
I am supplied with gid
For each of these I need to grab name from table wp_ngg_gallery
then join in table wp_ngg_pictures and grab field filename limit 1 order DESC by field imagedate
Anyone able to help?
Post Views: 3
Let me know how / if this works. If you dump both of those tables (out of phpMyAdmin) in a SQL format I will create local databases and give it a run myself (assuming this doesn’t work).
This is assuming you need a JOIN. It could probably be done with a decent
GROUP BY
statement.I’m going to guess:
If there’s a specific GID you want, you could do:
(The $gid is valid if you’re query is a string in PHP, you didn’t say, though, if that’s what you’re using)
It’s not clear if wp_ngg_pictures.galleryid is a foreign key to wp_ngg_gallery.gid but it’s the most likely choice given the info you supplied. If it’s not (if you can have galleries with no images), you might want to modify the other guy’s query (using the outer join) by adding
and wp_ngg_gallery.gid = $gid
to it.If you want it for multiple gids (choose the other options for a single one):