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


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 Complete Forum Thread with Replies

Related Forum Messages:
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 !
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 !
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 !
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 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 !
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 !
Multiple UPDATE :: Update 3 Rows
i'm trying to update 3 different rows in my DB...can this be done with one query ? i tried a couple different methods, but kept giving me errors

View Replies !
Update Replication, Force Update
Recently an error in the db on my master caused the slave to fail. I noticed this after a few days when I looked at the status and it said "Slave_SQL_Running: No". After looking further I saw what the error was on the master.

What is the best method of re-synching the databases?

Is there a command to force a re-replication or synch of the dbs? Would you delete the slave's db and update over? In this case, is there a command to pull the data down from the master?

View Replies !
Complex Query - UPDATE Within UPDATE?
Edit: Before anyone leaves this thread, don't be put off by the regular expressions! They are not the problem, so please stay and read.

OK, this query has got my head spinning. I am basically creating a query that goes through each product in a table to update the stock for that particular item with that particular size (i.e. I am talking about shoes - different models and each model has different sizes (uk kids 12 -> uk 11).

With each shoe it does (or is meant to do) the following:
1. The PHP script that runs the query is looping through every size outside of the query
2. So for each of these sizes it checks to see whether the product it is currently on matches the size it is on
3. When it finds the size it is on, it then deducts the correct number of units from the stock table
4. The final WHERE clause makes sure this subquery inside the UPDATE only happens when the StockUpdated field of the Product table equals 0 (in other words, the stock hasn't been counted before)

Basically what I need to do, is first to make sure what I currently have got does the above correctly but also I need the query to UPDATE the StockUpdated field to 1 only when it has been updated successfully. How could I do this? Unfortunately I cannot just add an extra update entry to the end of the query as this would update the StockUpdated field regardless of whether it has been properly counted or not.

Here is the query I have so far (with a little simple PHP around it doing the loop):


PHP

$shoesizes = array(1 => 'ukk12','ukk13','uk1','uk2','uk3','uk4','uk5','uk6','uk7','uk8','uk9','uk10','uk11');
    $numshoesizes = count($shoesizes);
    
    for($i = 1; $i < $numshoesizes; $i++) {
        $stockupdate = "
        UPDATE heelys_stock,items_ordered SET heelys_stock.size_".$shoesizes[$i]." =
            (SELECT
                CASE
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?( )?(Kids)?( )?( )?(UK)?( )?( )?(Kids)?( )?( )?[^0-9]12( )?(' -- if UK Kids 12
                THEN heelys_stock.size_ukk12 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?( )?(Kids)?( )?( )?(UK)?( )?( )?(Kids)?( )?( )?[^0-9]13( )?(' -- if UK Kids 13
                THEN heelys_stock.size_ukk13 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]1( )?(' -- if UK 1
                THEN heelys_stock.size_uk1 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]2( )?(' -- if UK 2
                THEN heelys_stock.size_uk2 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]3( )?(' -- if UK 3
                THEN heelys_stock.size_uk3 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]4( )?(' -- if UK 4
                THEN heelys_stock.size_uk4 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]5( )?(' -- if UK 5
                THEN heelys_stock.size_uk5 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]6( )?(' -- if UK 6
                THEN heelys_stock.size_uk6 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]7( )?(' -- if UK 7
                THEN heelys_stock.size_uk7 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]8( )?(' -- if UK 8
                THEN heelys_stock.size_uk8 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]9( )?(' -- if UK 9
                THEN heelys_stock.size_uk9 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]10( )?(' -- if UK 10
                THEN heelys_stock.size_uk10 - (items_ordered.Amount/items_ordered.Price)
                WHEN SUBSTRING_INDEX(items_ordered.Product,',',-1) REGEXP '( )?(UK)?( )?[^0-9]11( )?(' -- if UK 11
                THEN heelys_stock.size_uk11 - (items_ordered.Amount/items_ordered.Price)
            FROM items_ordered WHERE items_ordered.StockUpdated = 0)
                
            WHERE (heelys_stock.id = (SELECT heelys_stock.id FROM heelys_stock,heelys_shoe WHERE SUBSTRING_INDEX(items_ordered.Product,',',1) = heelys_shoe.full_shoe_name))
        , items_ordered.StockUpdated = 1" // at the moment this last update of the items_ordered table happens to every record!!! even if the other part of query fails

        
        // update stock for size $i
        mysql_query($stockupdate);
    }

Hope someone can see how I can do this? I've been working on this query for 2 or 3 hours now and I've been making reasonable progress but now I am really stumped.

View Replies !
Update Queries Do Not Always Update
We are running a MySQL database using PHP to create html pages and forms to update and add information to the db. Sometimes the update query works, sometimes it doesn't - or at least, not permanently. A new record may be added, but five minutes later it has sometimes, but not always, mysteriously disappeared.

Where should I look for a solution? Is there a cache that MySQL creates that may be being accessed unwittingly?

We are using the standard php and MySQL versions that come as standard on a Mac OS X Tiger 10.4.7 server. The browser we are using is Firefox 2.0.4.

View Replies !
ON DUPLICATE KEY UPDATE - Don't Have A Key But Want To Update
This may seem like more of a PHP question but I will come onto the MySQL part in a minute.

Basically I have a PHP script that lets users upload 2 different CSV files to different tables. The problem I have is that sometimes these CSV files are updated and then need to be reimported into the database through the script. I have made this script totally generic so that when you change the table that is being entered to the rest of the script will alter itself to import the correct CSV to that table. But a problem arises when I have a CSV file that contains each product sold and the shopper who bought the product (so the shopperID may appear in more than 1 row) - however this file does not have a unique id for each row meaning that when I use an INSERT INTO with a ON DUPLICATE KEY UPDATE... it will just insert more rows instead of updating rows because there is now key in the table.

The format of the table is like this (with some example data to show you more clearly):

+-----------+-------------+---------+------+--------+------+
| ShopperID | Product Code | Product | Price | Amount | Units |
+-----------+-------------+---------+------+--------+------+
546733 1315 prod 1 64.00 64.00 0
546733 1316 prod 2 43.99 43.99 0

OK just ignore the last 2 fields - that is a problem with the old system there was which does not add the units up right.

Anyway basically I might have the same shopper ordering 2 things which will come up on different rows - I have 3 things I cannot do:

1. I can't make the ShopperID field the PRIMARY KEY because I have many times where there are 2 rows with the same shopper
2. And I cannot just do an UPDATE when it gets to a duplicate entry because it will overwrite every time it gets to a shopper that already exists.
3. I don't want to add a unique primary key to the CSV as this will mean that the system I am creating loses its ability of being automatic because the person (an admin) that uploads the file will have to make sure that it has that extra field which is auto incrementing.

Does anyone have any ideas on how I can get round this?

Here is my PHP function which contains the query:
PHP

// this function for insert data to csv
function makeINSERTS($text, $table, $tablefields, $correctcsv){
    $insert = array(); //make array for hold data insert
    $i = 0;
    $success = true;
    
    while(list($key, $val) = each($text)){
        // Insert the data
        $insert[$i] = "INSERT INTO ".$table."  VALUES('";
        $insert[$i] .= implode("','", $val);
        $insert[$i] .= "') ON DUPLICATE KEY UPDATE ";
        foreach($tablefields as $k=>$field){
            $insert[$i] .= "`$field`='{$val[$k]}',";
        }
        $insert[$i] = substr($insert[$i],0,strlen($insert[$i])-1);
        // echo $insert[$i].'<p></p>'
        $result = mysql_query($insert[$i]);
        if(!$result) {
            echo 'FAILURE to insert/update any or all of the database form uploaded CSV!<br />'
            $success = false;
            die('Query failed: ' . mysql_error().'<br />');
        }
        $i++;
    }
    if($success == true && $correctcsv == true){
        echo 'SUCCESS in uploading the CSV file to the database!<br />'
    }
    else {
    }
return $insert;
}




View Replies !
Bad SQL Statement
I used Mysql with a lot of databases.I have only one binary log for all theses databases. If I have to recover one database because a bad SQL statement has destroye some datas.
The method :

1. I restore the database xxxx using mysqldump < xxxx.sql

2. I made a file with all the binary logs from the date of the databases backup and the curent binary log (all_binary.log)

3. Using vi editor I commente the row of bad SQL stament.

4. I apply the all_binary.log file by :

# mysqlbinlog all_binary.log | mysql

Question:

The bad SQL stament will not be apllied. All the SQL staments of the others databases will be apllied or not? Does exist a risk to use this method ?

View Replies !
SUM Statement
I have a database that stores the start_time and end_time for calls made to the server. I am building a simple server stats script that extracts some information but I am running into a problem with a query.
I need to get the total seconds for calls made to the server within a specified time period and to get the duration of one call I simply subtract start_time from end_time (times are stored in UNIX Epoch time). However, sometimes a call isn't terminated properly and a value of 0 is stored in the end_time field. This can throw my SUM(end_time - start_time) off because start_time exists but end_time is 0 giving me a negative sum at the end.

I want to write a query that does SUM(end_time - start_time) on records where end_time > 0 only. The IF statement I have is not working correctly. I am currently using:
SELECT COUNT(*) as TotalCalls, IF(end_time>0,SUM(end_time - start_time),0) as TotalSeconds FROM CALLS WHERE start_time>='1109059200' AND start_time<='1109145599';

My TotalSeconds collumn always ends up being 0.

View Replies !
SQL Statement,
Trying to count the number of times the game entered (either 1 or 0 in the database) equals the game winner (1 or 0).

Here is my SQL statement:

SELECT DISTINCT(users_id), SUM(case when game0 = '0' and game1 = '1' and game2 = '0' and game3 = '1' and game4 = '1' and game5 = '0' and game6 = '1' and game7 = '0' and game8 = '0' and game9 = '0' and game10 = '0' and game11 = '0' and game12 = '0' and game13 = '0' and game14 = '0' and game15 = '1' and game16 = '0' and game17 = '0' and game18 = '0' and game19 = '0' and game20 = '1' and game21 = '1' and game22 = '0' and game23 = '1' and game24 = '0' then 2 else 1 end) AS total_points FROM bowl_pickem GROUP BY users_id ORDER BY total_points ASC

However, it just returns a 1 for all of the users_ids.

View Replies !
Sql Statement!
I have my table (called data):

id integer(primary key)
rt integer
type varchar(100)
login varchar(100) foreign key

Here it is another table (called partition):
id integer foreign key references data(id)
idpartition integer

I want to write a sql statement which does this:
I want data.rt, partition.idpartition where login='whatIwant1' AND type='whatIwant2'.

I would like that with kind of statement, the dbms returns all what a 'login' has, not only that tuple where the type matches.
I tried with "union" but I am not able to do it.

View Replies !
LIKE Statement!
I have read about and tried many different variations using LIKE in a query but can't seem to get it right.
String = "I like to sing in the rain sometimes"
I would like to returns records with both "sing" and "rain" in the title, but not "singers" or "rainfall".

View Replies !
SET Statement ?
When i give the following command in command prompt it works fine, but when i use query analyser it doesnt , it gives me null , i dont know why ..

when executed via command prompt

mysql> SET @name='abc'
mysql> SELECT @name;

i get output as 'abc' as excpected

where as when i use the same thing in query anaylsyer , i get the result as 'NULL';

any setting that i need to do in query analyser ?

View Replies !
USE Statement
i've installed/configured mysql 4.0.21-standard! everything it's fine except that I don't know what privilege do I have to set to a new user so he can use the "USE" statement!

View Replies !
LIKE Statement?
run this script:

CREATE TABLE test (name varchar(20) NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8;

// insert "if 'o": [i], [f], [space], [backslash], [single quote], [o]
insert into test values ('if ''o');

// the next doesn't return the row
select * from test where name like '%if ''o%';

Why doesn't MySQL find that just inserted record?

View Replies !
VB6 With SQL Statement
My SQL statement gives and error when the user enter the value in the textbox having the apostrophe character.

if the value of my textbox is (men's clothes)

strtemp = "INSERT INTO DE(DESCRIPTION) VALUES('" & text1.text & "')"

sconn.execute (strtemp) //EXECUTE SQL COMMAND


i get the error

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 's';

View Replies !
&lt;&gt; In SQL Statement
I would like to ask you what to read to understand this "<> for queries.

SELECT polltext, votecount FROM poll_data WHERE pollid = '$pollid' AND polltext <> ''

What does polltext <> '' do?

View Replies !
Statement Help
I try for hours to get this update statement straight and I just can't see the error:
UPDATE voting_profil as p, voting_mitglieder as m set p.yahoo='gfj', m.geschlecht='weiblich',p.msn='ppppppp',p.icq='gfj', m.land='Deutschland', p.familienstand='fghj', p.sternzeichen='gfj',p.suche='fghj', p.hobby='fghj',p.treff='fg', p.sex='fgj', p.motto='fghj', p.po_eig='',p.ne_eig='', p.partner_eig='', p.sonstiges='' where m.mit_id='1' and p.mit_id=m.mit_id

It worked before, so I guess I just missed

View Replies !
Can This Be Done In One SQL Statement?
My Roster table contains rosterId as the key, userName as the field I want.
My Article table contains articleId as the key, rosterId as a foreign key, synopsis, article and posted as the fields I want
My Comments table contains id as the key, rosterId and articleId as foreign keys and posted as the field I want.

I want only one row returned that
Given the aritcleId
Contains the Roster.userName for the Article, the Article.synopsis, the article.posted (date), the Roster.userName for the Comments and the Comments.posted
where
1) The Comments row contains the latest posted (date) for the rows the Comments.articleId that matches the articleId above
2) uses the Comments.rosterId from the Comments table to extract the Roster.userName (for the Comment) AND
3) uses the articleId to obtain the Article.rosterId (which will be different than the Comments.rosterId) to get the Roster.username (for the article).

All tables use the innodb engine.

I understand how to do this in multiple selects, but suspect it could be done in one.

Yes? No?

View Replies !
Help With This SQL Statement.
I have a list of employees with titles and their office locations. What I want to do is to count the number of senior engineers out of the total number of regular and associate engineers at the location. All I can figure out is how to get the total number of engineers per locatoin.
What is the SQL statment that will give me the total number of "Senior Engineers" and "Total Number of Engineers" per "office"?
Here is my attempt which is totally wrong:
SELECT
COUNT ( title = "Senior Engineer" ),
COUNT ( title = "Senior Engineer" + title = "Engineer" + title = "Associate Engineer" ),
office
FROM
employees
WHERE
title = "Associate Engineer"
OR title = "Engineer"
OR title = "Senior Engineer"
GROUP BY
office
I want to the output to be like:
Number Senior Engineers, Total Engineers, Office
4, 20, Oregon
1, 10, Texas

View Replies !

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