mysql

how to generate the snippet like generated by google with PHP and MySQL?

Say,it just returns the snippet around which the searching keyword exists. And part of the text is replaced by "...". Is it possible to achieve that goal with PHP and MySQL? ...

Creating a php function to return mysql results

Im trying to create a function, that will return a mysql query, which i can then loop through and handle the results, but it doesnt seem to be working. I might not even be doing this the right way. function GetAccounts($username){ require("dbconn.php"); $result = mysql_query("SELECT * FROM `accounts` WHERE `username` = '$username' ") or...

Grouping Consecutive "Wins" in a Row

Given rows: symbol_id profit date 1 100 2009-08-18 01:01:00 1 100 2009-08-18 01:01:01 2 80 2009-08-18 01:01:02 2 -10 2009-08-18 01:01:03 1 156 2009-08-18 01:01:04 2 98 2009-08-18 01:01:05 1 -56 2009-08-18 01:01:06 1 18 2009-08-18 01:01:07 3 ...

List of all tables in database, and number of rows in each one?

Does anyone know what MySQL statement I would use to return results containing a list of all the tables in a database and the number of rows in each one? ...

Backup MySQL database

Hi, I have a MySQL Database of about 1.7GB. I usually back it up using mysqldump and this takes about 2 minutes. However, I would like to know the answers to the following questions: 1) Does mysqldump block read and/or write operations to the database? Because in a live scenario, I would not want to block users from using the database ...

MySQL: MIN() and MAX() against a string value

I have an SQL SELECT statement joining 2 tables. The main table contains misc information on a product and is joined to a second table of sizes. The second table contains a list of non-numeric sizes stored as a string and is simply structured as follows... SizeID = Primary Key SizeName = String value of size (i.e. Small, Medium, Large) ...

why connect to mysql is so slow ?

I use jdbc to connect to mysql, when it is at localhost:3306, everything is OK. but when i move my application to another computer in the intranet, and use Intranet-IP:3306 to connect to mysql database, it will consume around 1 minutes to connect to mysql successfully. what's up ???? Thanks in advance ! ...

utf8 problem with swedish characters from command line

I have a script that gets a string from the database, splits it into words and writes the words to the database. It works perfectly when i call the script via http (using apache web server). It also works to run it from a windows command line. However, when i try to run it from the command line (shell) in ubuntu all swedish chars ÅÄÖ is ...

How to speedup data retrieval from 2 servers on different hosts

I have a database server on host A, and some applications also on host A, on host B hosted by mediatemple i have application that needs to retrieve data from host A, this app works fine and super fast when on host A, but when on host B it's A LTO slower, it sometimes take 10 seconds to generate the page. Because slow SQL queries. I tri...

Easiest way to activate PHP and MySQL on Mac OS 10.6 (Snow Leopard)?

What is the easiest way to activate PHP and MySQL on Mac OS 10.6 (Snow Leopard)? I'd prefer to use any built in versions before resorting to downloading from the PHP or MySQL websites. I'm comfortable at the command line in Terminal. ...

Are unique indexes better for column search performance? (PGSQL & MySQL)

I am curious as to whether CREATE INDEX idx ON tbl (columns); vs. CREATE UNIQUE INDEX idx ON tbl (columns); has a significant algorithmic performance benefit in PostgreSQL or MySQL implementations when scanning the indexed column(s), or whether the UNIQUE keyword simply introduces a unique constraint alongside the index. I imagin...

How to deal with enormous line lengths created by mysqldump

I'm using mysqldump in a cron job to backup a database with over 2 million rows. It creates a text file which can be used to restore the datalog from the command line. I thought it would be useful to edit the dump before a restore as a quick way of changing values and table or column names - at least until I learn more and become confi...

MySQL commit and rollback

Hi Friends I develop a webpage in that i face this problem. please see below. In user table i have following fields: Userid password Address phone Email In service table i have the following fields: Ser_name ser_id USER_Refid All these are in same page in php. When i add values in service table it stores under the same USER_R...

MySQL, Get users rank

Hi Guys, I have a mysql table like below: id name points 1 john 4635 3 tom 7364 4 bob 234 6 harry 9857 I basically want to get an individual user rank without selecting all of the users. I only want to select a single user by id and get the users rank which is determined by the number of ...

Nysql trigger and

Hi all, I'm trying to create a trigger that monitor changes on a table and then insert those change to another table as follows CREATE TRIGGER userChangePasswd BEFORE UPDATE ON originalTable FOR EACH ROW BEGIN INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM originalTable END mysql keeps showing the following error ...

How to change collation of database, table, column?

Now the database is latin1_general_ci and i want to change collation to utf8_general_ci. Is there any settings in phpmyadmin to change collation of database, table, column? rather than changing one by one. ...

savepoint commit rollback in mysql

Hi friends how can we use commit rollback and savepoint in mysql ? ...

How to insert / retrieve a file stored as a BLOB in a MySQL db using python

I want to write a python script that populates a database with some information. One of the columns in my table is a BLOB that I would like to save a file to for each entry. How can I read the file (binary) and insert it into the DB using python? Likewise, how can I retrieve it and write that file back to some arbitrary location on th...

C# MySQL Lost Connection

Hi. I have C# application and I'm using MySQL database. Everything seems to be fine except one thing. Our computer network is little bit unstable. When I'm trying to execute query and the computer simultaneously loses connection to the mysql server (I'm simulating this situation by unplugging the network cable from computer which is mys...

How do you maintain revision control of your database structure?

What is the simplest way of keeping track of changes to a projects database structure? When I change something about the database (eg, add a new table, add a new field to an existing table, add an index etc), I want that to be propagated to the rest of the team, and ultimately the production server, with the minimal fuss and effort. At...