mysql

How to benchmark / test the speed of MySQL, Postgresql, MongoDB, where there are so many cache layers around?

I think with SQLite3, at least it doesn't keep any cached page because there is no server and each write will exit SQLite3, so it can't do any caching directly. But when it is MySQL, Postgresql, or MongoDB, there will be a layer which, when the data is thought to be saved already, it is actually in the memory cache of the DBMS... to be ...

How can I disable the phpMyAdmin login page?

I use phpmyadmin, and when entering this adress: www.mydomain.com/phpmyadmin a login page appears. Is there any way of disabling it, so it doesn't appear/exist? Thanks ...

UPDATE record if present; else INSERT

I want to update a record which may or may not be present in a table. If it is not present in the database then it will be inserted. To prevent from select I am using UPDATE statement first and checking affected_rows > 0 if not then I am inserting this record into the table. I was wondering if there is a better way to do this? ...

More efficient way to COUNT() MYSQL rows via PHP?

Here is how I am currently counting mysql rows in PHP: //GET total # of results and build $start and $end for main SQL statement $sql= 'SELECT COUNT(*) FROM savedsearches WHERE user_id=\''.mysql_real_escape_string($user_id).'\''; $initial_query = mysql_query($sql) or die("SQL error"); $num_sql = mysql_fetch_array($initial_query); $numro...

"WHERE column IS NOT NULL" with Kohana v3 Query Builder

Is it possible with Kohana v3 Query Builder (Kohana v3 being possibly the most poorly documented #$@$%...) to use the IS NOT NULL operator? The where($column, $op, $value) method requires all three parameters and even if I specify ->where('col', 'IS NOT NULL', '') it builds and invalid query eg. SELECT * FROM table WHERE col IS NOT ...

fix mysql query to return random row within subgroup

Hi All! I'm using the following query to randomly draw one row from the subset, for each ID1-ID2 pair, of records that have the minimum distance in time (YEAR and MMDD fields). CREATE TABLE temp4 AS SELECT * FROM temp3 GROUP BY ID1, ID2 ORDER BY DATEDIFF( CONCAT(YEAR,'-',LEFT(MMDD,2),'-',RIGHT(MMDD,2)), CONCAT(ID3_YEA...

Determining the number of occurrences of a record

I have two tables - student and interview - with values: student ---------- sID sName interview ---------- sID date outcome = (OFFER, NOOFFER, HIRED) And I have to list the sID of any student who has never received an offer but who has had more than five interviews. I am having trouble figuring out how to determine if a ...

Handling Local and Remote DB in Django

I'm using Django and MySQL to serve a website. I have my own MySQL server on localhost for my site. Now I have a third-party MySQL database that I need to use to read and write to that is on a remote host. I set up the new database's information in my settings.py file, but a problem occurs when I try to access the remote DB. Because the ...

Mysql and PHP LIKE query generates no results on page but returns result in Mysql

Im using a multiple LiKE queries on a table in mysql, The query is being generated from another table and then sent to Mysql. The actual query when run generates results but when i run it on the page it returns nothing?? Secondly there must be a simpler way to run the same query using less LIKE command maybe mysql_query("SELECT FROM fm...

MySQL .NET Connector Subselect Join Problem

The .NET Connector for MySQL definitely speeds up development but recently I've begun looking at the MySQL query logs and was surprised to see that my joins become subselect joins. I even updated to the latest version of the .NET Connector and it's the same thing. I'm using it with the Entity Framework in .NET 3.5. I figured it would ...

Order by max value in three different columns

I'm not even sure it's possible to do this but I want to order a query based on the maximum value of one of three columns. Example table structure: guid, column1, column2, column3 Columns 1-3 have numerical values and I want to order the select statement based on the maximum value of 1, 2 OR 3. For example: record column1 column2 c...

PHP error when using mysql related functions

I have another script that I can't figure out what is wrong with it. I attempted to use the error_reporting(E_ALL); to report the errors, but it doesn't report anything. Anyway, here is the code I'm having trouble with. <?php error_reporting(E_ALL); $username = $_POST['user']; $email = $_POST['email']; $password = md5($_POST['pass'])...

MySQL - Getting historical "snapshots" from a history table

I have a MySQL database that has verious one to many relationship fields (eg orders and order_items) Each time an order_item is changed, the record is also inserted into the order_item_history table with the timestamp in the modified field. What I need to do is query the database to get the state of the order based on a particular date...

PHP MySQL and Queues, Table Locking, Reader/Writer Problem

I have following Scenario: PHP(Server, Writer) ----> MySQL Database <------ PHP(Client, Reader/ Writer); PHPS = PHP Server PHPC = PHP Client How it works? PHPS writes data to temporary database tables (queue_*). PHPC is triggered by a 1 hour cron. PHPC starts, connects to database and caches all records locally (how? no idea, lo...

error in mysql query, does not return MIN value...

I'm trying to get this query to work. The query was written by "OMG Ponies" as an answer to: http://stackoverflow.com/questions/3796228/fix-mysql-query-to-return-random-row-within-subgroup The query below calculates correctly the difference in dates, but then fails to select the ROW (within ID1-ID2 pairs) with the minimum value of tha...

SQL QUERY problem bookid

How do Find books (show their titles, authors and prices) that are on 'CIVIL WAR' (i.e., the title field contains 'CIVIL WAR'), available in 'AUDIO' format. this is my schema * Books (bookid, title, author, year) * Customers (customerid, name, email) * Purchases (customerid, bookid, year) * Reviews (customerid, bookid, ...

Rails 2.x and Unicode

I've read several Stack Overflow questions re. this and haven't been able to find an answer. I'm running Rails 2.3.3 and am having an issue properly displaying Unicode characters from MySQL in my app and even in the Rails console. Connecting to MySQL via my ssh console and querying works fine. However, soon as I retrieve a record co...

Best way to code a big one-click toggle button to replace a single checkbox and submit button form?

I've got a page that has a simple one checkbox form with a submit button for users to mark that item as "want to play." Given the simplicity, I'd like to replace it with a single DIV and graphic of a toggle button or switch or something, so that users can click it to mark, but not have to bother with the silly single checkbox and submit...

Lock visitor until mysql query is complete

I have a bunch of pages on a site for which the actions that can be taken on one page are contingent upon the info in the database for the site visitor. So, let's say Visitor A comes to page B and updates a database to show that they have joined a certain group. Then the visitor goes to page C, the group page. If the user is a group memb...

How to dispaly image from MySQL table to PHP page in table format ?

I am working on image uploader in which the user uploads the image to the mysql database via a simple HTML/PHP form. It works, and now I want to retrieve the saved images from MySQL in a HTML table format. But I am not successful. I am very much a novice in PHP. I have attached the currently used code... can someone please help me creat...