mysql

How to reverse the default ordering in Mysql?

In Mysql, when you execute a select SQL statement, there is a default ordering if you don't include a sorting clause, how to reverse the default ordering? Just add DESC? ...

Concurrency / Synchronization question

I have 2 programs running on 2 different machines. Each program has a method called updateRecord that does the following 2 things: 1. Do a SELECT query on a particular record Z 2. Do a UPDATE query on the same record. If these 2 queries are in the same transaction (between beginTransaction and commitTransaction) does it guarantee proper...

The procedure works in MySQL 5, but fails in MySQL6, why?

Procedure: delimiter | create procedure pro_regs(in username varchar(50), in pwd varchar(50), in email varchar(50), in address varchar(50)) begin insert into regists ( `user_name` , `user_psd` , `user_email` , `user_address`) val...

alternative to mysql_fetch_array()

I want to execute a query and either it will return one row or none. I don't want to use mysql_fetch_array(). What else can I do? ...

Apache httpd error and crash

I have a WAMP 2.0 server installed on Win XP . Apache version : 2.2.11 PHP Version : 5.3 MySQL : 5.1.36 I have about 11 tables in the mysql . Each run of my web application (HTML/Jquery/PHP/MySQL) fills about 100 rows in 2 of the tables.(One of the table has 2 Long blob columns where data of size upto 20MB is uploaded, I have changed...

Fatal error: Call to a member function prepare() on a non-object

Hi, We have a Document Management application. I have 5000 image files loaded in mysql DB. Need to delete them when the folder is deleted at the client. Using the following code, public function delete($dbh){ $sql = "DELETE FROM fileTable WHERE FID=:fid; DELETE FROM file_blobTable WHERE FID=:fid"; $stmt = $dbh -> p...

Force "implied AND" instead of "implied OR" in mysql boolean match?

In mysql boolean match, if no operators are present, OR is implied. If you want AND, you need to add + to each keywords. So query "word1 word2" is equal to "word1 OR word2", "+word1 +word2" is equal to "word1 AND word2" I don't want users to have to enter + before each keyword, what are my options? Suggested option 1: Is there some...

Mysql change number in column

Here is an easy question for someone. When using mysql, how do you increase or decrease the number in a particular cell by a specified amount with a single query. For example i have a product table with 5 x product a. I sell 1 item and i want to update the field. I want to do it with one query, not get the number add to it and then updat...

How to create a snapshot or clone of PHP, MySQL page... Inspiration needed

Hi, We have a web application that creates a dynamic PHP page with all the MySQL stored details a user has entered via a number a forms. So far so good, but we want this information stored some how to be refereed to at a later date, as an administrator can make changes to the data, which reflects on calculations that are worked out fro...

only image uploading and displaying that from database

Hi frnds really i dont know how to vote today i came to know,dont neglate my que thinking i have not accept...i am begginer to development i want to upload only image to database and that i need to fetch and display..i should fetch directly image and display can anyone please help me out thank in advace ...

Creating a range of numbers in an sql subquery

Is there a better way to generate a range of numbers in SQL than below? I'm using MySql. SELECT tens.x + ones.x + 1 FROM (SELECT 0 x UNION ALL SELECT 1 x UNION ALL SELECT 2 x UNION ALL ... SELECT 9 x ) ones CROSS JOIN (SELECT 0 x UNION ALL SELECT 10 x UNION ALL SELECT 20 x UNION ALL ... SELECT 90 x ) tens; ...

Using post array from paypal

I am using paypal to process payments on my site. Paypal returns the post array like [item_number1] =12 [item_name1] = My product name [quantity1] =3 [item_number2] =14 [item_name2] = My product name2 [quantity2] =5 [num_cart_items] 2 Insert step here now im just going in circles getting nowhere And then run the for loop for($i = 1;...

MySQL query fetching siblings

I need a query that will fetch a single item before a certain Id and an item after that same Id. For example I have five rows, id's 1 to 5 and i need to select id before and after id 3, so that I get 2 and 4 as a results. Is there a way to do it with a single query? Edit: I forgot to tell that maybe results would not be siblings but...

How to get the latest created table in MySQL?

Hi, I have a MySQL database and every 6 months, a new table is created with the latest entries. What SQL command can get you the latest created table in a database? Many thanks ...

How to efficiently use MySQLDB SScursor ?

Hi, I have to deal with a large result set (could be hundreds thousands of rows, sometimes more). They unfortunately need to be retrieved all at once (on start up). I'm trying to do that by using as less memory as possible. By looking on SO I've found that using SSCursor might be what I'm looking for, but I still don't really know how...

Mysql read data immediately after writing?

I am using a MySQL DB and a Java JDBC client to access it. I have a Table that contains session information. Each session is associated with a SessionToken. This token is a Base64 encoded String of a Hash of some of the session values. It should be unique. And is defined as varchar(50) in the db. When I try to lookup a session by its...

Is mysql_insert_id thread safe?

Hi! I'm using MySQL C API to build a db client application, and i need to get the last autoincremented value in a INSERT statement, so mysql_insert_id does. But this client is multithreaded and a piece of code like this: mysql_query(conn, query_string); value = mysql_insert_id(conn); I don't know what will it return, this query auto...

Getting error when INSERT into MySQL.

_mysql_exceptions.Warning: Incorrect string value: '\xE7\xB9\x81\xE9\xAB\x94...' for column 'html' at row 1 def getSource(theurl, moved = 0): if moved == 1: theurl = urllib2.urlopen(theurl).geturl() urlReq = urllib2.Request(theurl) urlReq.add_header('User-Agent',random.choice(agents)) urlResponse = urllib2.urlop...

MySQL sort by name

Is ir possible to sort a column alphabetically but ignoring certain words like e.g 'The' e.g. A normal query would return string 1 string 3 string 4 the string 2 I would like to return string 1 the string 2 string 3 string 4 Is this possible? EDIT Please note I am looking to replace multiple words like The, A, etc... Can this b...

Catch cause of 'too many connections' in mysql

I have a mysql server which is occasionly returns the 'too many connections' error. I have worked with the server admin to set the mysql and server vars up to the best. We reckon it's down to a query which takes extremely long, then locks a table and thus backups others. Was wondering what would be the best way to catch this problem? ...