php database phpmyadmin without a value

Hi, I have a phpmyadmin question:

I have 2 tables:

table 1:


id   |    cat_id
1    |    150
1    |    155
1    |    350
2    |   101
2    |   104

table 2
id    |  first_name
1     |   Ron
2     |   Jan

I want a database selection to do this:
If  "cat_id" is not  "350"  then  I get    "first_name" = Jan.

This is what I have, What I get with this is a list with Ron and Jan.

$q = "SELECT, hfw_post_notif_subscriber.first_name, hfw_post_notif_sub_cat.cat_id FROM hfw_post_notif_subscriber, hfw_post_notif_sub_cat WHERE = GROUP BY";
$sth = $db->prepare($q);
            <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
            <h1>Lijst alle klanten</h1>

            <table class="lijst">
                        <th align="right">ID</th>
                        <th align="left">Naam</th>
                        <th align="left">Actie</th>
                        while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
                                          <td align="right"><?php echo $row["id"]; ?></td>
                                          <td width="50%"><?php echo $row["first_name"]; ?></td></tr>
I hope someone can help me to take care of the following:

I want a list with the "first_name" except when "cat_id = 350".
In this case only "Jan"
Ron BaasDirecteurAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What happens when there are 3 or more people? For example:


id   |   cat_id
1    |   150
1    |   155
1    |   350
2    |   101
2    |   104
3    |   110

id    |  first_name
1     |   Ron
2     |   Jan
3     |   Henry

Open in new window

If cat_id is NOT 350, do you want both Jan AND Henry?

It's a little unusual to do a NEGATIVE query (show me everyone who DOESN'T match this selection), so I want to make sure that I'm understanding your situation correctly.
Ron BaasDirecteurAuthor Commented:
Hi gr8gonzo

Yes, thats correct,  I want both Jan ANd Henry
Okay, so here's the raw query:

SELECT ...your desired fields... 
FROM hfw_post_notif_subscriber 
  (SELECT id FROM hfw_post_notif_sub_cat WHERE cat_id=350)

Open in new window

Just substitute in your variables.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ron BaasDirecteurAuthor Commented:
Fantastic gr8gonzo,

it works great!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.