PDA

View Full Version : Need help on an sql query


silverd
06-08-2011, 02:52 PM
Little stumped.

I want to display all posts that contain an [IMG] tag and are not in a deleted thread.

Something like:

SELECT * FROM post WHERE pagetext='[img]' WHERE thread.threadid=post.threadid AND thread.visible=1

--------------- Added 1307553941 at 1307553941 ---------------

still trying

SELECT * FROM post WHERE pagetext LIKE '%[img]%' WHERE post.threadid=thread.threadid AND thread.visible = 1

BirdOPrey5
06-09-2011, 12:30 AM
You need to JOIN the thead table onto the post table...

Try


SELECT * FROM post, thread WHERE post.threadid=thread.threadid AND pagetext LIKE '%[img]%' AND thread.visible = 1

silverd
06-09-2011, 02:59 AM
SELECT pagetext FROM post, thread WHERE pagetext LIKE '%[img]%' AND post.threadid=thread.threadid AND thread.visible = 1

^^^
that got it workin