Update Values
I made a mistake converting some time data to unix timecodes while adding some data to a database, and now I noticed some of these dates need to have 15 hours added to the timestamp. So I though about doing a
Code:
UPDATE ntk_news SET date=date+54000 WHERE newsid>0 AND newsid<178
after having a look at the MySQL manual for Update . Did not work, unfortunately.
Anybody knows what I am doing wrong? I took 54000 since that is ~15 hours. The WHERE statement works in a SELECT clause, but then copy-n-pasted into this UPDATE clause it all breaks.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Update With Values
I would like to update an existing row from table A with some values from another row in table A.I've tried several things, also something like the combined "insert into/select" however it did not work saying its not valid SQL. UPDATE A SET value1=b1.value1, value2=b1.value2 SELECT value1, value2 FROM A; Any idea what could be wrong? Is the idea valid in SQL after all?
Update And Add On Values
I have a table that has acculumative hours for each member. I want the members to be able to type in two times, then the code to get the difference between the times and add it on to what is already in the database under their name. Is this just an UPDATE query, or is there more specy stuff involved?
Update A Table With Values In Another
I have the following table tableA column_a column_x column_y column_z tableB column_x column_y column_z How do I update the rows of tableA that match rows of tableB (all rows of tableB are unique) What I want to acheive is a check against tableA.column_x with tableB.column_x, if they match, then update the row in tableA.column_y with the value of tableB.column_y and tableA.column_z with tableB.column_z
How To Update Values In A Column
I have a price list that needs increasing by 10%. Is there any way to do an update commmand and multiply all values in the column by 1.1 to achieve this? I've tried various commands but to no avail.
Update Table Values
I have a csv.txt file with contacts and their information in it. Then I also have a table in mysql with the same contacts and their various information. I need to merge these to so that if a field value in the database is NULL the value that is in the csv.txt file is inserted into the database field. I have been looking at the mySQL site on how to do this but have not been able to produce a working solution. Below is a more detailed example of what I am looking for. Code:
Automatic Update Of Values In Another Db
I am trying to integrate a CMS and a fourm. As a solution, whenever there is a change in the users table of the CMS db I want to have it automatically changed (updated) in the forum db as well. Can anyone recommend a solution? Please note that the two user tables differ in structure, just some columns match, like password and such.
Update Values In Column
i have a table with about 500 rows, i need to UPDATE the city column in each row. I want to remove a comma (",") a space (" ") and the 2 letter state abv ("FL") from all values in the column (named 'city'). example: "Miami, FL" should become "Miami"
Update Query Where Values Will Come From Other Table
I'm creating an update query which the value will come from another table. I have here my current query which unfortunately makes the system hangs. Probably because of the query itself is not properly coded. update boxes b inner join messages m on b.ctnnumber = m.ctnno set b.consigneerecv = m.CName, b.consigneerecvdate = m.DateRcv, b.phrecventered = "Y", b.PhilStatus = "delivered", b.prevreleasestatus = b.releasestatus, b.releasestatus = "delivered", b.PhilStatusDate = m.smsrecvdate, b.phdelprice = "0.00", b.phdelamt = "0.00", b.recvrelation = m.Relation, b.APRecventered = m.smsRecvDate where b.consigneerecv = '' or b.consigneerecv = 'NA' or b.consigneerecv is null; I'm thinking revising it so that it will not cause the system to hang but I don't know how. Guys please help me with this one. I also have this another idea which probably will not work. My idea was something like this: Update table1 set table1.column1 = (select table2.column1 where table2.column1 = table1.column1), table1.column2 = (select table2.column2 where table2.column1 = table1.column1), .....
Update Values On Inserting Duplicate Index
I am very new to mysql. I have a question about using the "on duplicate update" clause with insert command. my table "data" has two columns, field1 and field2, where field1 is the index and is "unique". when I run insert ignore into `data` ( `field1`,`field2`) values (1,2) (2,6) (2,9) (5,1) I got 1,2 2,6 5,1 because the third value pair, (2,9) was ignored due to duplication in field1. here is what I want to do: when inserting new record with duplicate index, I want the existing record gets updated. in the above case, I want the output look like the following after the insert command: 1,2 2,9 5,1 after searching mysql online document, I only found the "on duplicate update" clause can do something similar, however, all the examples only show setting the duplicate record to somthing unrelated to the new values.
How To Insert And Update Multiple Values In One Record
How do I insert and update multiple values in one record. e.g. 1. How do I insert "dogs,cats, snakes" in one record 2. If I have "dogs, cats, snakes" in one record and I want to update it and add 'pigs' to make it "dogs, cats, snakes, pigs", how do I do that?
Update One Table Value With Values From Another Table
I am trying to update one table value with values from another table, and I cannot get it to work. What am I doing wrong? This is my SQL-command: UPDATE tabel1 SET tabel1.name=tabel2.name WHERE tabel1.ID=tabel2.ID
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.
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?
Unable To Update - Have Update Priveledge
I've been granded update priveledge to tables in a few databases on our server: Select_priv ,Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, and Lock_tables_priv are all set to 'Y' for a selected database. I can connnect and read the data and data definitions just fine. I cannot insert, update, delete, create, or alter any table in this database. Our admin worked for a couple of hours yesterday trying to resolve the issue, but no joy. I've googled for this problem and the most relavent posts I've found were problems related with users not being able to connect. I can connect and I can read, I just can't do any of the other priviledges.
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; }
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.
Get All Values
Is it possible to just return all the values that are in a column?
Two WHERE Values
I dont even know what to search for on this. Is it at all possible to have two WHERE values on a query? Would I maybe put an and symbol or something? what is the proper syntax for something like this, or is it even possible? SELECT * FROM Hotlines WHERE date_opened='20050203'
First And Last Values
Is this the most efficient way of performing this action? SELECT (SELECT `Date` FROM mytable ORDER BY `Date` LIMIT 1) AS FirstDate, (SELECT `Date` FROM mytable ORDER BY `Date` DESC LIMIT 1) AS LastDate
Sum Of Values
I'm working on something that I don't have much experience with. I have the following query: select item_no, sum(price), count(*) from production where date > '2006-11-15' group by item_no; which returns: item_no --- sum(price) --- count(*) 27714 --- 327.6 --- 6 29582 --- 269.64 --- 4 38599 --- 476.34 --- 6 Is there a way that I can get the total of the sum(price)? Do I need to do this in PHP?
Top 2 Values
I have a table called Labs and a table called EE's. Each EE has many labs in the lab table. I am trying to figure out how I find the top 2 labs (based on date) and return that along with all of the fields in the EE table. Would I use a sub query? Something like this? SELECT * FROM ee, WHERE ee.id in (select top 2 from labs). This didn't seem to work.
Max Values
is it possible to set a maximum value for a column? I want to have a max value of 100 so if the current value is 98 and the query tells it to update by a value of 3, it will still update it but only up the maximum.
In Between Values
i got a table [code] type points ... 4 100 5 200 6 300 ... now..lets say i got 150 pts...so that will fall to type 4... so whats the proper sql statement for that?
Getting Values From Row
One way that I determine the most recent insertion into a table is to get the highest id value in the id field. Using the auto increment function whenever a new record is inserted in the table, the hightest id number by default is the most recent submission into this table. I would like to create a query that pulls up all the data from the row with the highest id number. I know that to get that number, I can use the max(id) approch, but I don't know how to enter this into a sql statement, and get the other values that attach to it. I tried "select name from table where id=max(id) but I get a group error reply. What can I do to get the values I'm looking for?
Get Rid Of Values
This is it, say i have six numeric fields to fill in. What i need is to get rid of the biggest and smallest numbers among these six fields, so i can take into account just the middle four left fields. It's a system for ranking persons performances. For example: field#1= 6.3 field#2= 2.3 field#3= 7.5 field#4= 4.9 field#5= 8.3 field#6= 4.5 and i need to get rid of the biggest and lowest entered values, in this case, i should get rid of fields #2 and #5
Sum Values
Let's say I have a messages table with a points column, where points may be 0, 1, 2 or 3. Is there a way to selectively sum the values for each id except for points equal to 3 ? The query below sums everything, even when points equals 3. SELECT id, SUM(points) AS total_points, COUNT(*) AS num_messages FROM messages GROUP BY id
Total Sum Of Values?
this isn't a question of "how do I do this" but more of a "what's the best efficient way of doing this" the current code is: $result=mysql_query("SELECT votes FROM list"); votes is always a numerical value what's the most efficient way to add the total value of the votes?
Trigger Old And New Values
I have two tables with some fields. RealTableName ID int FieldOne varchar FieldTwo varchar OldValuesTableName ID RealTableNameID FieldOne FieldTwo I want to create a trigger which transfers the current values of the `RealTableName` record I am updating to the `OldValuesTableName`. This should happen before update.
Returning All Values
I'm sure this is a straight forward and obvious one: I have this: SELECT * FROM tbl_contacts WHERE con_Customer = "#URL.con_Customer#" Which obviously when you pass a value over the url returns the relevant records. How can I pass a value to the url which passes ALL the records back. Is it something like ?con_customer='%'?
Get The Enum Values
how can I get the variable that enum field can take it? like if I have Sex field that could take (male,female) . I need something like that: select (all the values for the sex field) ; //output (male,female).
How Do I Get Values From Select?
I need to assign values pulled by a select query to varibles, but the only thing I know how to do with the values I get from a select query is make a table. Below is the code that puts the values I need stored in variables in a table: $query = "SELECT title, description, height, width FROM images WHERE filename = '$imagepath'"; $result = mysql_query($query) or die (mysql_error()); echo "<TABLE BORDER=1>"; WHILE ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "<tr>"; WHILE ( list ($key, $value) = each($row) ) { echo "<TD>" . $value . "</TD>"; } echo "</TR>"; } echo "</TABLE>"; Its designed to call only one row so I just need the four values called in the query to have their own variable,
Getting Values From Row With The Largets Id
One way that I determine the most recent insertion into a table is to get the highest id value in the id field. Using the auto increment function whenever a new record is inserted in the table, the hightest id number by default is the most recent submission into this table. I would like to create a query that pulls up all the data from the row with the highest id number. I know that to get that number, I can use the max(id) approch, but I don't know how to enter this into a sql statement, and get the other values that attach to it. I tried "select name from table where id=max(id) but I get a group error reply.
Ordering Values
How do i order numbers retrieved by there value, such as: 1,2,3,4,5...12,13...22 so its like that instead of 1,11,12,13,14,2,21,22,23,24,31,4,5,6...
128 Bit Values As Primary Key
Suppose that 'bigkey' is a column capable of representing the value of a 128-bit unsigned integer in some efficient fashion... maybe as a CHAR or VARCHAR field big enough to hold its decimal or hex representation, or maybe some other datatype, and ${128bitvalue} is a representation of it acceptable to MySQL. Suppose 'smallkey' is an UNSIGNED INTEGER column. Which of the following two queries is likely to be faster and more efficient? SELECT somecolumn, anothercolumn FROM foo, bar WHERE foo.bigkey = ${128bitvalue} AND bar.bigkey = ${128bitvalue} SELECT somecolumn, anothercolumn FROM main, foo, bar WHERE main.bigkey = ${128bitvalue} AND foo.smallkey = main.smallkey AND bar.smallkey = main.smallkey If MySQL had a native 128-bit integer type, it would probably be a no-brainer to just use it directly. Unfortunately, as far as I know, there's no way to store a 128-bit integer in a MySQL column without converting it into some alternate representation first. Assuming that I'm still better off using the 128 bit value's representation directly as the key instead of joining it via a third table, what's the most efficient way to represent that 128 bit value to MySQL? CHAR(39)? VARCHAR(39)? Some other format?
Between Values Of 2 Columns
Consider the following table: FROM_HERE-----TO_HERE-----VALUE 1--------------------10--------------------a 11--------------------20--------------------b 21--------------------30--------------------c How could I get the VALUE(a,b or c) of a $number that is between FROM_HERE and TO_HERE? For example $number = 17; 17 is between 11 and 20, so VALUE = b. (Note that 11 and 20 must be included, so if we have $number = 11 or $number = 20 -> VALUE must be "b")
Retrieving Values From Url
i want to put the value in a variable but dont know how to retrieve it: i want to use record_num = 3 as a variable: URL: .../review.php?,record_num=3 EXAMPLE OF VAR $link_id ='[record_num]'; SOURCE <a href='review.php?,record_num={$row['link_id']}'>LINK</a>
Values NOT In Range
I want to find all values for a field NOT in a range. In this case, I want to see which membersIDs are NOT used say between 1000-1000. Finding the used ones is dead easy, but I can't find a simple way (besides creating a list of all numbers between 1000 and 10000) to get the ones that are NOT used.
Grouping Only Top 10 Values
I am trying to figure out how to run something complex like this: my table structure is similar to this: player_id player_points each player has alot of rows with points. The way we have our listings displayed is by doing a SELECT player_id, SUM(player_points) as total GROUP BY player_id ORDER BY total DESC. This works great but now we need to change our queries to reflect only top 10 scores of each player. So if a player has 50 entries for different points, we need to grab only the top 10 points and find the sum of that. Our table has over 20 million rows. Can anyone guide me on how I would go on doing this? One way is by passing row by row into php and counting only top 10 rows. But this means going through all 20 million rows through php, very ineffective.
Adding Values?
How can i add the values of different rows in mysql using php? ie: id field! 1 3 2 2 3 4 4 2 5 6 6 20 7 7 8 5 n 1 ----------------- total = value of id#1 upto id# n. for this example total should be = 50
Row Values COUNT
I'm creating database that has three rows Month, dtate and values. There I want to get count all values in some month rane. then I used query like this... SELECT month, values ,COUNT(*) FROM table_test where month between month1 and month3 group by month That query result was How many row in the that month period. But I want to count the values in the that row( values row).
Round Values
How do I round values in a view. Do I change the table? The type that needs rounding is currently formatted as double.
How To Get Different Values From The Column
I am reposting my question here as there's no reply from the other post (different subject). In the column, there are mixture of multiple same and different values. How do I write to obtain all different values with the limited row? For example, select pet from pet_customers where ?????? order by Date Desc limit 25;
Find Value Not In Between Values.
I have a SQL question I am having trouble with. We have a table, with a column that contains a code. These codes start at '00001', '00002', '00003', '00004'... and so on. If the record containing '00003' as it's code is deleted from the table, is there an SQL statement that can be used to find the first missing record. I guess what we are looking for is the lowest value of CODE not in the list of values between two values, such as in the case '00001' to '99999'.
Add Values Into A Column
I have a column called year with the format YYYY-MM-DD, but I would like to have year, mount and day in three different columns in my database. How can I do this?
Get Min & Max Values Of A String
I have a field 'zip' in a table in my database that records values in the form on 'something/023/something', 'anything/346/somemore','kztt/1984/asdg' I want to get the min and max values of this field in particular the numbers in the string. Initially, I simply run a query to get the min and max value of this field which works until the numbers in the string went to 4-digits instead of the usual 3. Example query: select min(zip) as min, max(zip) as max from $dbtable Then I run an explode function to retrieve the numbers in the string. This query now return values like min=999, max=1000 instead, when the min number should be 023 and max is 1984
Modifying Row ID Values
I want to be able to delete a row in a table, and then have every row's ID from below that row to subtract one, in order to move up. Here's how I have it, and I'm sure I'm doing something wrong. $query = "DELETE FROM tbl_image WHERE id = '{$_GET['del']}'"; mysql_query($query) or die('Error : ' . mysql_error()); $query1 = "SELECT FROM tbl_image WHERE id > '{$_GET['del']}"; mysql_query($query1) or die('Error : ' . mysql_error()); $result2 = mysql_query($query1); while($row = mysql_fetch_array($result2)) { $id = $id - 1; $query2 = "UPDATE tbl_image SET id = '$id'" mysql_query($query2) or die('Error : ' . mysql_error()); }
Return Values
SELECT someNumber, COUNT(someSubject) FROM someTable WHERE (someNumber BETWEEN 10 AND 20) GROUP BY someNumber The query returns the count for someSubject, grouped by someNumber providing at least one matching someSubject was found for each someNumber. Where there were no matching someSubjects, the someNumber group is not returned. Specifically, I am getting back the count for 16, 17, 18, 19 and 20. Although the count for 10, 11, 12, 13 and 14 is zero, I still want this to display in the returned table. Can any help to show me how I can force the BETWEEN values to display when the count for that value is zero?
|