I want to generate a list from 2 Tables based on some conditions in each table.
In Table 1 the primary Key is user_id
In Table 2 this user_id is the foreign Key.
So user_is is the field that these 2 tables have in common.
Now I want to generate a list which is list of articles in Table 1 but only if these articles based on user_id have no password in Table 2.
I have tired this but it is not producing correct results:
SELECT article_id, blog_name, title FROM articles, blogs
WHERE articles.user_id = xyz AND posted2blog = 0 AND articles.user_id = blogs.user_id
AND (blogs.blog_passwd = "" OR blogs.blog_passwd IS NULL) ORDER BY article_id DESC LIMIT 10;
The problem is that it is pulling up articles from those Blogs that do have a password which it should not as per: (blogs.blog_passwd = "" OR blogs.blog_passwd IS NULL)
What is even worst, or an indication of the problem is, it is indicating, via "blog_name", that it has pulled an article which belongs to a Blog that does not have a password but that article belongs to another Blog all together which does have password!
Thanks for your assistance.