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


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





UPDATE Statement Doesn't Work


TABLE - abc

ID NAME
___________
1 hello
12 abc


UPDATE `abc` SET `ID`='5' AND `NAME`='hello' WHERE `ID`='1' AND `NAME`='hello'

wherenver I try to update this table using above sql statement, it doesn't work. I just get "Row match:1 Changed:0" message.




View Complete Forum Thread with Replies

Related Forum Messages:
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?

View Replies !
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";

View Replies !
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.

View Replies !
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%';

View Replies !
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.

View Replies !
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

View Replies !
Sql Statement Doesn't Work
When i was using a previous version of mysql (3.something) this sql statement worked fine.

strSQL = "SELECT COUNT(*) as COUNTER FROM prayerrequest where dateexpires <= '" & sDate & "'"

sDate equals todays date.

But after installing the new version (4.1) of mysql this statement no longer works.

I went as far as stepping through all dates and comparing them and it wouldn't work. "1/11/2005" from the database did not equal sDate which was "1/11/2005".. The only way I could get it to work was to use the asp/vb function FormatDateTime on dateexpires and then compare it with sDate.

Does mysql not return a different var type? Is there anyway I can convert dateexpires in the above sql statement so I can compare it with sDate?

View Replies !
Cannot Get 3 Where Statement To Work
I am having a problem with MySQL 5. I cannot get 3 where statements to work with my database. Any two of the three work fine and return records as they are supposed to but when I add a third clause (all clauses are AND) I get absolutely no records at all and no error message. I don't understand what could be causing this and can use any help offered.

SELECT this, that, otherthing FROM myTable WHERE something = "this" AND somethingelse = "that" AND yetsomethingelse > 0 ORDER BY RAND() LIMIT 3;

View Replies !
Cannot Get Select Statement To Work
I can't for the life of me figure out why my select statement will not retrieve the data from MySql. it is a very simple statment;

mysql_query ("SELECT pub_type, call_number, pub_author, pub_title, subtitle, edition, publisher, publication_year, physical_description, series, isbn, holdings, subjects FROM library WHERE id=" .$pub_id);

but when I try to echo any of these variables I get nothing showing for results. the $pub_id displays because it is set by a GET function.

echo "<b class='foo'>$pub_id $pub_author $series </b> ";

I use a select statement on the page that calls for this page and it retrieves info from the database not problem... my includes for database connection, etc are all in tact.

View Replies !
Update Doesn't Work - 1064 Error
The code:

update course_series_assignments as c, users as u
set c.user=u.UsersID
where c.user=u.User;

...returns an error "1064-You have an error in your SQL syntax near 'as c, users as u set c.user=u.UsersID where c.user=u.User;' at line 1".

The c.user column currently contains varchar data like "John Smith", as does u.User. The u.UsersID column contains an auto-incremented unsigned integer. I want the integers to replace the full names in the c table where they match the User column in the u table.

View Replies !
Multiple-table UPDATE Does Not Work
I installed mysql-server-3.23.54a-11 and mysql-3.23.54a-11 rpms on RH9. Everything works fine. But when I try multiple-table UPDATE statement, it show me syntax error:

SQL statement:

mysqk> update country,city set country.cCode='A' where country.cCode = '1' and city.areaCode = country.cCode;

Error message:
ERROR 1064: You have an error in your SQL syntax near 'city set country.cCode='A' where country.cCode = '1' and city.areaCode =country.' at line 1

View Replies !
SQL-Update-Statement
I have to update all UA-fields in the table idrz_kennzahl with primary
key idrz, where the same idrz in the table per_verwaltung with the
field Amt=12 is.I designed following statement but it doesn't work:

update idrz_kennzahl
set UA=1234
where
idrz_kennzahl.idrz =(SELECT per_verwaltung.idrz from per_verwaltung where
per_verwaltung.Amt=12

View Replies !
Update With If Statement
I'm trying a statement which I cannot figure out what I'm doing wrong on. I've tried every combination that I can think of and stared myself blue with no success.

update cdr set Cost=if(mod(BillSec,6)=0,int(BillSec/6),int(BillSec/6)+1)

The idea is to update Cost with a value depending on the result of a formula. It's an empty field which gets a computed value from other fields. cdr is the table.

View Replies !
Update Statement
I am currently updating a table and increasing a column value by 1, the problem is that he don't increase 1 but it does increase the double of the value specified.
Why does it performs the update like this? And how can i solve this problem?

SQL Statement Syntax used: UPDATE table_name SET column_name=column_name+1 WHERE id=1

Version of MySQL: 4.1.7 for Windows installed in Windows 2003 Server.

View Replies !
What Would This Update Statement Be?
I have an array of ids formatted like 1,2,3,4,5

I have a table where there is a field that selects maybe a few of those ids, and is formatted like this: 1,3,5

View Replies !
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 Replies !
It Doesnt Use My Index!
`player_1` mediumint(7) unsigned NOT NULL default &#390;'
`player_2` mediumint(7) unsigned NOT NULL default &#390;'
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

View Replies !
Long Old UPDATE Statement
I have the following SQL which gives me the row Im after

SELECT *
FROM staff, staffemails
WHERE staff.users_username='$user'
and staff.staff_id = staffemails.staff_id

thing is I now want to perform an update on the result of this query. Ive tried

UPDATE staffemails
SET is_registered ='0'
WHERE staff.users_username = '$user'
and staffemails.staff_id = staff.staff_id .

View Replies !
Select And Update Statement
Is it possible to combine a select and update statement in mysql? If
so, what is the syntax.

View Replies !
Update Statement Not Working
Why does this simple update statement not work with a mysql version 3.23.49,
it does work when using 4.0.24..... ?

UPDATE listitem,vjbase,list SET listitem.showsec = 7 WHERE listitem.id_vjbase = vjbase.vjbase_id AND listitem.id_vjbase = 3 AND vjbase.id_viduser = 61000 AND listitem.id_list = list.list_id AND listitem.id_list = 1 AND list.id_viduser = 61000

View Replies !
Very Slow Update Statement
I am having an issue with an UPDATE statement that takes a very long time. I am using
1 table in a schema to update another table in another schema. Below are the create statements and the update statment I am using. Table and column names have been changed to protect the innocent :) Code:

View Replies !
Special UPDATE Statement
UPDATE some_table st SET some_page_no=((select count(*) FROM some_table WHERE some_table_id<st.some_table_id and some_id=st.some_id and some_type='OK') div 10)+1 WHERE some_id=345 and some_type='OK'

I want to use the above to make a fast page index (10 on each page). I had something similar in mssql and it worked, but in myssql I get this error:

"You can't specify target table 'some_table' for update in FROM clause"

What have I done wrong or can the above simply not be done?

View Replies !
UPDATE / JOIN STATEMENT
i have problems after updating mysql from 4.x to 5.0.19. This statement should update about 3000 rows but it only does 15 but there are definitely another 2000 rows with an older date and matching nr!

UPDATE tab1,tab2
SET tab2.newdate = NOW()
WHERE tab1.nr=tab2.nr;

I tried the variation with inner joining tab1 as well. same result.
Does anyone has an idea solving this problem? Perhaps it´s a bug?

View Replies !
Select + Update In One Statement
I have these statements.

$selectdata = "SELECT * FROM imagetrack WHERE fimsid = ".$_GET["fimsid"]." AND name = '".$_GET["service"] . "'";

$query = mysql_query($selectdata) or die(mysql_error());
$update = "UPDATE imagetrack SET seen = seen+1 WHERE fimsid = ".$_GET["fimsid"]." AND name = '".$_GET["service"] . "'";

Basically i was wondering if there was a statement where i can select everything and update the seen in one statement.

View Replies !
Conditions In UPDATE Statement
i have some data to be updated in a specific row - WHERE id=1

data:
$min_time, $max_time, $time, $attempts

so, i would like to calculate new avg and replace min_time with new value, if new min_time is smaller then that one stored in the database.

"UPDATE mytable SET
avg=(avg*attempts+$time) DEV (attempts+1),
min_time=**here i could use help** ??IF(min_time>$min_time)$min_time ELSE min_time??
**and similar with max_time .

View Replies !
Update Statement Problem? Plz Help.
I've a simple doubt of whether can or can't i update two tables by using joins as below. the below update statement matched 2 rows one each for two tables but didn't update.

mysql> update audio join pcr_info on audio.audio_sid=pcr_info.pcr_sid set audio.
audio_pid=4896,audio.audio_prgm_num=3,audio.audio_type="MPEGLayer1",audio.audio_
sr=44.1,audio.audio_mode="1_0",audio.audio_bitrate=320,pcr_info.pcr_pid=49 where
pcr_info.pcr_prgm_num=3 and pcr_info.pcr_sid="2501" and audio.audio_pid=4896 an
d pcr_info.pcr_pid=49;
Query OK, 0 rows affected (0.00 sec)
Rows matched: 2 Changed: 0 Warnings: 0

View Replies !
DELETE,UPDATE Or Other Statement In WHERE
I would like to let my admins write WHERE statements. . In panel where you can see all users of my site, admin should have input where he can put some filters in WHERE statment. E.G. standard query is
SELECT login FROM USERS .
and admin would write age > 18 and male = 'f'
. php script would conact it and it would execute
SELECT login FROM users WHERE age > 18 and male = 'f'
I have question about security of this solution. Is possible to put in WHERE statement sobe dangeurous statemetns like DELETE of UPDATE?

View Replies !
Conditional Update Statement
I have a table with a field of ID numbers. I want to update this field and replace the ID numbers. For example I want every record that currently has the ID number 2,5,6,or 9 to be replaced with a 1. Every record with 1 or 4 to be replaced with 2 ...

I can't seem to form the update statement to do this. I can do them one at a time but this won't work because if I change 2,5,6, and 9 to 1 then when I run then update for 1 and 4 it will change them all. Does this make any sense?

I want some way to be able to use a condition...if id=2 or 4 or 6 set it to 1 and if id= 1 or 4 set it to 2.

My failed attempt:

mysql> update client_software set software_id=1
WHERE (software_id=2 or software_id=5 or software_id=6 or software_id=9)
AND software_id=2 WHERE (software_id=3 or software_id=7 or software_id=8)
AND software_id=3 WHERE (software_id=1 or software_id=4);

View Replies !
Insert Or Update In One Statement
I sometimes find myself writing PHP code that checks for a value in a table and updates it with a new value if it exists, or insert it into the table if it doesnt. Is there any way to do this with one sql statement?

View Replies !
Conditional Update Statement
MySQL Code:
UPDATE     tournamentsSET     tournament_player1 = IF (tournament_player1 = 5, 1, 0),  
    tournament_player2 = IF (tournament_player2 = 5, 1, 0), 
    tournament_player3 = IF (tournament_player3 = 5, 1, 0), 
    tournament_player4 = IF (tournament_player4 = 5, 1, 0) 
WHERE    tournament_time = 1 AND tournament_game = 1 ....

View Replies !
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.

View Replies !
Convert SELECT Statement To UPDATE
How do I convert the following SELECT statement to UPDATE statement? If I'm not mistaken, UPDATE statement could not involve more than one table.

SELECT * FROM F0116 LEFT JOIN F0101 ON F0116.ALAN8=F0101.ABAN8 WHERE F0116.ALCTR='' AND F0101.ABMCU='1'

View Replies !
How To Do EXPLAIN For DELETE/UPDATE SQL Statement?
Anyone know how to do EXPLAIN for DELETE/UPDATE SQL Statement?

cause I only can see execution plan from SELECT statement. And anyone know if there is third party software which allow me to see the UI execution plan like MSSQL Query Analyzer?

View Replies !
Update Statement Not Working On Server
this works on my machine but not where my site is hosted. They do use an older version of mysql could that be problem

update inv, newprice set inv.cost = newprice.price where inv.itemcode = newprice.itemcode

works fine on my machine her ebut on server i get error..

View Replies !
Update Statement :: Affected Rows: 0
UPDATE `zipLocations` SET `z_zipCode` = '06001' WHERE `z_zipCode` =6001 LIMIT 1 ;

Field Type Attributes Null Default Extra Action
z_zipCode int(5) No 0
z_cityName varchar(50) No
s_stateAbbr char(2) No
z_countyName varchar(50) No
z_areaCodes varchar(50) No

I even went through phpmyadmin found the row clicked on the edit button for that row and updated it. and it still doesn't update.. im' thinking it has to do with the data type being INT...

Why doesn't it update it ?.. It says it was successful.
Affected rows: 0 (Query took 0.0002 sec)

View Replies !
CASE Statement In Update Command
I'm trying to update one table (tbl_usage) based on information from another table (tbl_subscriptions) joined by the userID. The usage table tracks the number of times a user hits a page, and decrements the count each time. When the user has a zero count, they are redirected to a warning page.

Each week the count is reset depending on what type of license they have (licenseType) and how many of those licenses they've bought (numLicenses). A group license (G) gives them 100 hits, and an individual license (I) gives them 5 hits.

I'm trying to use a case statement to perform this count reset operation, but I can't seem to get it to work. The following case statement works just fine: Code:

View Replies !
Convert A Nested Update Statement
i have a nested update statement in my sql server as follows
UPDATE DIM_EVENT .

SET INVOICE_AMOUNT =
(SELECT SUM(INV.INVOICE_AMOUNT_TOTAL)
FROM INVOICE INV
WHERE INV.INVOICE_REFERENCE_NUMBER = DIM_EVENT.OBJECT_ID
AND INV.INVOICE_AMOUNT_TOTAL IS NOT NULL)
WHERE DIM_EVENT.EVENT_TYPE_CODE IN ('OFULN', 'OAUTH', 'CRDRL');
what is the equivalent in MySQL.

View Replies !
Update Statement :: Data From One Table To Other
I have two tables, and I want to take data from one table, and overwrite it onto the second. Unfortunately, my SQL is pretty weak.

The first table has a mediumtext column and a id (primary key) column. The second has an id (the same as the first), a number, and a mediumtext column.

I want to take the contents of the mediumtext field with the highest number and replace the contents of the field in the first column with it with the same id.

My instinct is to do it this way:

update forum1post p
set p.pagetext = (select query1.message
from (select pe.message, max(pe.editnum)
from forum1post_edits pe
group by p.postid) query1)
where p.pagetext = 'Why did you all flame my topic. Screw your ****ing forums.'
and p.postid = pe.postid

However, that does not work, as pe is not recognized.

View Replies !
Help With Simple SQL Statement To Update Zipcodes
I have a varchar(5) field in a database called 'zip_code'. I imported some zipcodes from an Excel spreadsheet, but the spreadsheet had truncated any zipcode that started with a "0" and removed the zero, so the correct zipcode of "08993" was incorrectly placed into the record as "8993".

Would someone help me write a SQL statement to run on the field zip_code that would look at the data, if it was four characters long, add a "0" to the start and keep the remaining four characters in place?

View Replies !
QUERY One Table And Update Another In ONE Statement?
ZIP_CODE:
zip_code
latitude
longitude

customers:
customer_id
...
zip_code
latitude
longitude

The lat and long in the customers table is blank. I want to lookup customers' zip code in the ZIP_CODE, get the related lat & long and update the customers table with that information. The result being that after this query is run, the customers table now has lat & long data.

View Replies !
Identify Columns Changed By Update Statement
It says in the documentation that "If you set a column to the value it currently has, MySQL notices this and does not update it." is there anyway to identify what column values have changed? i.e. what columns have been updated?

View Replies !
MySql Update Or Insert Statement To Modify A Word In All Caps
I have a field in my database called Subtopic. In this field I have a word LITERATURE in all caps. I need to change the word LITERATURE to LITERATURE followed by a colon then an empty space. Can someone give me the MySql statement I can paste into phpMyAdmin to make this change? Note: The Subtopic field contains the word "literature" but not in all caps because the Subtopic field is part the database that is an encyclopedia. Therefore, I want to change ONLY the word LITERATURE if the word LITERATURE is in all caps.

View Replies !
SELECT Doesnt Select Anything WHERE Doule
I am running the next script
SELECT * FROM flcc_Tickets WHERE 'Match No'=1;
but dont get any results although there are lots of resords with 'Match No'=1 in a table. 'Match No' is DOUBLE . if run it with 'Match No'=0 i get all the table.

View Replies !
Bug Work
I've got this bug http://bugs.mysql.com/bug.php?id=27861. I know they've made a fix and it's going to come out in the next version but is there any way I can fix this myself?

View Replies !
How Does Sql Work Exactly?
Well what exactly does sql do when you create a table for like a login (user) What does the tables and stuff do. Do they just create like a library to store that users information so they can log back in to site or w/e....

View Replies !
Subselect Does Not 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.

View Replies !
Date_add Does Not Work
I'm using mySQL 5.0, with a database of UNIX timestamps. Can someone explain this to me? This query works great:

 SELECT from_unixtime( 1132277574 ) 

But this one breaks:

 SELECT date_add(from_unixtime(  1132277574 ), interval 1 week)

Telling me, oh-so-helpfully, that the error is near "'week)'". (It doesn't work when I use "1 weeks" either.)Does the from_unixtime simply not work with the date_add function, or is there some arcanity to this syntax that I'm missing?

View Replies !

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