Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




WHERE Doesnt Equal


I am trying to select something my DB where a clause does not equal something but for some reason I cant seem to make it work.

Here is what I have tried.

PHP Code:

SELECT * FROM golf_groups WHERE name!="something" 


but this doesnt seem to work. i had done something like this before and thought that I had done it this way, but since this does not work,




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
It Doesnt Use My Index!
`player_1` mediumint(7) unsigned NOT NULL default Ɔ'
`player_2` mediumint(7) unsigned NOT NULL default Ɔ'
reffering to users' id-number in another table.

I have two indexes:

KEY `one` (`player_1`),
KEY `two` (`player_2`)
The cardinality of them is 6000 and 7000. My primary-key has cardinality 150 000.

When i run this query:

EXPLAIN SELECT *
FROM `gamebase`
WHERE player_1 =1
It uses the "one"-key (doh!).

But now, that I run my next query (using OR), it tells me that one and two are possible keys, but it uses neither, but loops through my entire table "Using where".

EXPLAIN SELECT *
FROM `gamebase`
WHERE player_1 =1
OR player_2 =1

Not Equal To
I'm trying to build a query that will take field "name" from two tables and list me out those that are not in both tables. I tried
SELECT id FROM users u, temp t where u.name <> t.name;

It just loops me out of all result, over and over and over... I also tried with != but doesnt help.

Not Equal
hi
from which version not equal work

this query does not give me correct result
1.
SELECT DISTINCT U.USR_ID,E.EMP_ID FROM USR AS U,EMP_MOD AS E
WHERE
E.EMP_ID != U.USR_ID

2.
SELECT DISTINCT U.USR_ID,E.EMP_ID FROM USR AS U,EMP_MOD AS E
WHERE
E.EMP_ID<>U.USR_ID

both does not work
does not equal not support

Its Returning A Value That Doesnt Exist
Okay here is the deal. I am running a query to find out if there is an ID in my table that has a case number that matches the one being submitted. If there isnt once its should step into an if statement that would submit a number of records. Otherwise it should jump to the else statement.

I the problem comes from: the query keeps returning "Record id#2" but there is no record matching the case number being submited from the form.

if( isset($_POST['Submit'])){ //Begin If statement logic
$resultcheck = mysql_query("SELECT * FROM submissions WHERE wfmcase = " . $_POST['wfmc']) or die(mysql_error()); //Query string to test if wfmcase was already submitted
echo "Sucess, form varibles have been passed.<br />";
echo "Resultcheck query results: $resultcheck <br />";

if ($resultcheck == ""){ //Checks to see if the query was empty.
echo "There are no duplicate case escalations pending. <br />";

I added the echo statement so that i could see how far it was getting through the script. It dies after printing the varible $resultcheck which gives "Record id#2". It never enters the 2nd if statement because for what ever reason the query has the "record #id2" in it... What is causing this? I have verfied that there is no case that matches the one coming from the form and i get the same error.

Subselect Doesnt Work
i am trying to remove values from a list menu if the join table
doesnt have keys when a key is selected for instance:
locations
locationID

locations_join
locationID shotlistID

SELECT SQL_NO_CACHE l.locationID , l.location FROM locations l LEFT JOIN
locations_join lj ON l.locationID = lj.locationID WHERE l.locationID NOT IN
(select locationID FROM locations_join WHERE shotlistID IN (5069)) ORDER BY
l.location ASC

so when shotlistID is selected all the keys from the locations_join joined
to the shotlistID would be remove from the locations list please help, i'm
trying to do this in one query saving from getting all the keys into an
array then checking if the values arent in the array when generating the
list.

GROUP BY Doesnt Work
i have a table that contains the folowing fields:

some_table:

company_number
something_number
price
date_price_established

for a certain company i need to get all the dates that prices were established. and i dont want any date_price_established to repeat themselfs.

for example, for the following database:

1,1,15.5,1.1.2006
1,1,16,1.1.2006
1,1,17.5,1.1.2006
1,1,16,3.1.2006

the results will be : 1.1.2006, 3.1.2006.

this is what i've tried:

SELECT date_price_established
FROM myDb.some_table
WHERE company_number = 1
GROUP BY date_price_established";

Where Clause Doesnt Work
im creating a website with a mysql database. ive jus got started. im havin a few problems
i have a product table and i execute a simple query but it doesnt seem to give me any results: heres the query:

Select * from product where ProductName = 'Age of Empires III';

the above query doesnt work but this 1 does
Select * from product where ProductName LIKE 'Age%';

Subselect Doesnt Work
i am trying to remove values from a list menu if the join table d=
oesnt have keys when a key is selected for instance:
locations
locationID

locations_join
locationID shotlistID

SELECT SQL_NO_CACHE l.locationID , l.location FROM locations l LEFT JOIN lo=
cations_join lj ON l.locationID =3D lj.locationID WHERE l.locationID NOT IN=
(select locationID FROM locations_join WHERE shotlistID IN (5069)) ORDER B=
Y l.location ASC

so when shotlistID is selected all the keys from the locations_join joined =
to the shotlistID would be remove from the locations list please help, i'm =
trying to do this in one query saving from getting all the keys into an arr=
ay then checking if the values arent in the array when generating the list.

Domain Name Now Doesnt Work
I have a software script I had installed on my server that works with a mysql database. It was working fine as far as pulling information from the database under my old domain name, however, I changed to a new domain name as primary on my server and now the database does not pull anything into the template.

I know this is probably simple but not sure how to fix this.

Function Doesnt Work
i tried write simple function:

CREATE FUNCTION `getLastNumber`(some_guy INT(50), date DATE) RETURNS float
BEGIN
DECLARE a FLOAT;

SET a = NULL;

SELECT number INTO a FROM numbers p WHERE p.number_owner = some_guy AND p.date_created <= date ORDER BY p.date DESC LIMIT 1;

RETURN a;
END

that would return last inserted number into table for some person. When some_guy has number in table, then is everything ok and it returns last number, but when some_guy does not have row in table it returns: Query OK, -1 rows affected. Pls why? and how to fix it?

Mysqldump Doesnt Work
i try to insert the followind data to mysql database
mysqlimport -u root -p anaktisi2 < phpbb_db_backup.sql

But this doesnt insert anything in the db.

Subselect Doesnt Work
i am trying to remove values from a list menu if the join table d=
oesnt have keys when a key is selected for instance:
locations
locationID

locations_join
locationID shotlistID

SELECT SQL_NO_CACHE l.locationID , l.location FROM locations l LEFT JOIN lo=
cations_join lj ON l.locationID =3D lj.locationID WHERE l.locationID NOT IN=
(select locationID FROM locations_join WHERE shotlistID IN (5069)) ORDER B=
Y l.location ASC

so when shotlistID is selected all the keys from the locations_join joined =
to the shotlistID would be remove from the locations list please help, i'm =
trying to do this in one query saving from getting all the keys into an arr=
ay then checking if the values arent in the array when generating the list.


Equal To MS-SQL CONTIANS
what do u know abt the equal to the MS-SQL clause of CONTAINS in mySql?

Equal Auto_increment Key
I have a field in one of my tables which should initially equal the primary key of the row, concatenated with a char (in this case VL). For example ID might be 40, and the field in question would therefore be VL40.
I am relatively new to MySQL and cannot figure out how to do this. I have tried something along the lines of
iNSERT INTO table(id, field) VALUES (NULL, CONCAT('VL', id));
but this always has field to be VL0. I have also tried using LAST_INSERT_ID(), but again this always returns 0! What am I doing wrong?
Also, I realise that initially the data in these fields is duplicated, but I may need to change the value of this field later on and so do need to keep the two fields in my schema.

Why Doesnt Limit Work Fully
Why is it, when you have a query, and you limit something, it doesntlimit the records searched? such as, i have a query that searches for "joe" and puts it in ASC order and limit 5, itll go through all joe's, is limit only good for displaying records, such as only 5 records show, ? if that made any sense :)

Query Quandary : Not Equal To
***Don't hesitate to point me to the manual ...if you know where the answer is. I could not find what I needed.***

I have a table with 7 columns, 3 of which are 2006, 2005, 2004.

I want to return rows in which both &#55614;&#57157;' is not = 0.00 and 2006 is not = 0.00

Find Equal Rows
what could be the easyest (and shortest) way to find all doubled rows in a table? any function with mysql, or should i select all and then compare in php?

Full Text Searsh Doesnt Work
I am trying to do a Full text search, but I have two problems.

1. If I enter a word that is found under multiple entries, I get no return. But it i search a word tha's only under one enetry, then it works.

2. This query works:
PHP

SELECT * FROM `site` WHERE MATCH (site_name,keywords) AGAINST ('mice') AND `approved`=&#391;'

, but when I add WITH QUERY EXPANSION, it doesnt work.

PHP

SELECT * FROM `site` WHERE MATCH (site_name,keywords) AGAINST ('mice' WITH QUERY EXPANSION) AND `approved`=&#391;'

I get this error:


MySQL said:

#1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH QUERY EXPANSION ) AND `approved` = &#391;'
LIMIT 0, 30' at

MySQL Select Datetime Less Than Or Equal To
I am using MySQL 4.0.18 and I have a field named "order_datetime" in
which I store data in the format 20041001 23:00:00 (for example Oct 1,
2004 11pm)

When I do a select statement to find dates in a given range, the
result set never includes records that have the ending date. For
example, if my SQL statement is

Select * from HH_Will_Call where (order_datetime >= (20041001) and
order_datetime <= (20041003)) order by order_datetime

It will only include records through Oct 2, even though I know there
are records in the table that have Oct 3!

As you can see, I am using the less than or equal to operator, yet I
have this problem with any date range. How can I get the ending date
to be included?

How Can I Get The Default Value Equal Current Datatime?
i created a table.one of it's fields default value is current datatime? i write sentence like this:

CREATE TABLE `test_dbo`.`test` (
`a` DATETIME NOT NULL DEFAULT 'now()'
)ENGINE = InnoDB;
i get the prompt like this"invalid default value for 'a'"

what can i do for this?

Drop Down Menu: Option Equal To All Others In The List
I would like to create a drop down menu in a form that selects distinct arrays from a columname, inserts them into a drop down menu, but then I also want one of the options to be equal to all of the rest. I would end up with a drop down structured like this:

All colors
Red
Blue
Green
Purple

Looping Through MySQL To Change The Id (using PHP) To Equal The Number Of Rows
When deleting a row from the database, that id is now missing.
So what I'm trying to do is update in a loop (maybe an sql loop if
there is one) of all of the id numbers - sort of like renaming them.
It did partly work because all the id's were set to 22. Thats because
there was 22 rows.

Here's the code I used:

How To Use Equal To"==" Operator In If Condition
i am using a "if condtn" in a stored procedure where
i am chekn if "checkid" is equal to 1 or 2 so i m writing seprate if conditions for this.

Like:-
if(checkid==1) then
#######
end if;
if(checkid==2) then
#######
end if;


bt i am getting an error like:
Error Code : 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1
end if;
end if;
if(checkid=2) then

I am not getting this error...
is there anything wrong in if condition syntax or in condition.
Hw should i write the if condition then...???

Mysql Queries "does Not Equal"
hey. is there a way to perform a mysql query if you want all the results EXCEPT for rows with specific ids?

ex. I want all the clubs except for the club where id="3"

Fill Up NULL Data With Data Whose ID Is Equal
I have this table

id name
-----------
1 Daniel
1 NULL
2 Marc
1 NULL
2 NULL

and I need this one

id name
-----------
1 Daniel
1 Daniel
2 Marc
1 Daniel
2 Marc

How To Store &quot;≤&quot; (less Or Equal To) Into Mysql As Is?
I need to insert some data from excel sheet to mysql tables. Characters like "≤" (less or equal to) turn out to be question marks, after they are inserted.


Copyright © 2005-08 www.BigResource.com, All rights reserved