SQL help...

Jun 30, 2007 23:13

Question:

For those of you with servers, what version SQL are you running?

This works fine on my home server - but not on my hosting server.

SELECT category, category_ID FROM categories WHERE category_ID NOT IN (SELECT category_ID FROM stories_category WHERE story_ID = '1')

My host's going to upgrade me to MySQL 5 (finally...) but I'd like to know if I need to code this for 4.x if that's what most people use...

And, erm, I /think/ I've done it with joins:

SELECT categories.category, categories.category_ID FROM categories
LEFT JOIN stories_category ON categories.category_ID != stories_category.category_ID
WHERE (stories_category.story_ID = '1')

But it doesn't return everything in categories if there's no stories with story_ID in the stories_category like I need it to... portilis, windiain, kimble any ideas?

(And, yes, I know part of the reason I got my new job is 'cause I can use databases - but I HATE joins in raw SQL...)

Thanks!
Previous post Next post
Up