Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 MySQL Query Problem

Author  Topic 

Weirfire
Starting Member

2 Posts

Posted - 2005-04-05 : 12:01:22
I'm trying to write a MySQL query for my PHP file and wondered if anyone could solve the problem.

It's a little trickier than usual but I'll try to explain it and show what I have come up with already.

Table A fields : ID and Variable
Table B fields : ID and Status

What I would like is a query which shows a count of the number of results we get from Variable being X from table A and where the Status is not StatusA or StatusB.

So far the query which I've come up with is

[CODE]$Result = mysql_query(
"SELECT COUNT(*) AS count
FROM TableA
INNER JOIN TableB ON TableA.ID = TableB.ID
WHERE TableA.ID = '$X'
AND TableB.Status !== 'StatusA' || TableB.Status !== 'StatusB'"
);[/CODE]

How am I doing with this query?

mr_mist
Grunnio

1870 Posts

Posted - 2005-04-05 : 12:03:32
This is a Microsoft SQL server forum so you might get better help elsewhere, but I think for the correct boolean logic you would need

$Result = mysql_query(
"SELECT COUNT(*) AS count
FROM TableA
INNER JOIN TableB ON TableA.ID = TableB.ID
WHERE TableA.ID = '$X'
AND (TableB.Status !== 'StatusA' || TableB.Status !== 'StatusB')"
);


-------
Moo. :)
Go to Top of Page

Weirfire
Starting Member

2 Posts

Posted - 2005-04-05 : 12:07:43
Thank You Mr Mist.

I'll give that a shot. I did realise that it wasn't the exact same version but I've used Oracle and Access for running SQL Queries and have found that the queries themselves are not that different.

I've tried my luck on a few forums so hopefully if your solution doesn't work, then someone elses will :-)
Go to Top of Page
   

- Advertisement -