mysql

Get duplicate entries from a table

How can I get rows that were inserted more than once from a table? I allow my site users to have only one account per email but my script had a little bug so users where able to register more than once with the same email address. I want to get all the emails that has been recorded more than once. How is that possible using php/mysql? ...

MySQL + PHP (grouping by date)

I'm trying to output a list of different itmes grouped by the date they were stored in the database (unix timestamp). I'd need help with both MySQL (query) and PHP (output). MySQL table id | subject | time 1 | test1 | 1280278800 2 | test2 | 1280278800 3 | test3 | 1280365200 4 | test4 | 1280451600 5 | test5 | 1280451600 ...

Using a constant just once, in a SQL request

I am performing this request, and I get the results I want: UPDATE sales SET color = ( SELECT color FROM master WHERE productcode = "XJ2" ) WHERE productcode = "XJ2"; But now I use a BI transformation tool where I can enter the constant ("XJ2" here) only once. S...

Mysql gem with MAMP

Hi, I'm running MAMP for local development on Snow Leopard (64bit obviously). I'm trying to run a rake task for a ruby on rails application and get the following error: " !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. !!! The bundled mysql.rb driver has be...

MySQL: Not unique table/alias: 'favourites'

Hello folks. The error I'm getting is: Not unique table/alias: 'favourites' I apologise for the reasonably intense query(!): SELECT code.id AS codeid, code.featured AS featured, code.title AS codetitle, code.summary AS codesummary, code.author AS codeauthor, code.date, code.challengeid, ratingItems.*, FORMAT((ratingItems...

phpmyadmin: how to remove time limit to import big databases

how can I remove the time limit for the import operation in phpmyadmin ? I'm not able to upload a big database because of the limit and I have to login again in the database. Thanks ...

how to find which field is duplicate

My table is having four fields in which two fields are unique. They are username and email for example. People register in the front end. I dynamically display the result of their registration using ajax. I am doing a single insert query. And if there is an error then i use the error number to find whether it is 1062(duplicate entry) or...

Does the setting time_out in mysql affect JDBC connection pool?

It's usually set to 60 seconds. But I think con pool will hold the connection, so is there any conflict? Thank you. ...

MySql Transactions

So I have two methods. Method one adds a row to my database. Method two selects and updates the latest 10 rows of the table. If method one adds a new row after method two selects the data but before it updates it will method two update the wrong 10 rows? Will transactions help here or do i need to lock tables? function one(){ inser...

Cannot save characters of my language

Hi, I am trying to save some data(name, last name) in my forms with php and mysql. It's simple form like: <input type='text' name='first_name' /> And php gets it after submiting with: $first_name = trim(mysql_prep($_POST['first_name'])); The problem is, that if I type characters in my languege(lithuanian), it won't save them and w...

MySQL query stuck in a queue become a bottleneck

Recently, sometimes I cannot open my site. I'm using VPS for hosting. and when I do mytop it shows me: User Host/IP DB Time Cmd Query or State -- ---- ------- ...

Querying a MySQL db representation of a tree

I have two tables that represent parent/child nodes, their types, and their relationships: Table 1 | nodeID | node | name | type | | 1 | A | test | Type A | | 2 | B | abcd | Type B | | 3 | C | defg | Type C | Table 2 | parentNodeID | childNodeID | | 1 | ...

INSERT new rows, UPDATE old rows: how?

I am making a PHP utility that imports and analyzes a CSV file into $data, and whether or not to INSERT "new" rows into the database ($saveNew). Right now, I have a bit of an ugly mess: (in generalized pseudo-PHP) function synchronize($data,$saveNew) { $existing_ids = $table->find_all('ID'); //array of ID's in the table $incomi...

What is the most efficient way to insert a large number of rows from MS SQL to MySQL?

I need to transfer a large number of rows from a SQL Server database to a MySQL db (MyISAM) on a daily basis. I have the MySQL instance set-up as a linked server. I have a simple query which returns the rows that need to be transferred. The number of rows will grow to approximately 40,000 rows, each row has only 2 char(11) columns. T...

Where's the source of mysqlclient.lib ?

I have a C++ application which connects to a MySQL server. It all works fine. Currently it uses libmysql.dll. At build time I link to libmysql.lib. As far as I understand I can link to mysqlclient.lib instead and get rid of the dependency of libmysql.dll, i.e have the functionality embedded within my exe. My question is: Where can I f...

flot graphing with mysql and ajax

Hi guys, i've finally zoomed down on how to dynamically plot graphs using flot. its been a journey. currently i've got function draw() on setInterval for every 5 seconds. My Mysql table is constantly updating, and my phpfile (response.php) echos the last value. The php looks like this: //Get the last row $result = mysql_query("SELECT * ...

mysql statement that skips the table if a feild doesnt exist

i have an array of all the tables in my database and i need to go in a delete the record if the applicationid=123 or familyid=123. but some tables dont have any of those feilds is there a way i can just skip the table if that is the case? instead of it erroring. $query2="DELETE FROM "$table[$x]" WHERE applicationid = '517f20805d9bd0961...

problems generating "checked" checkboxes from a MySQL generated list of checkboxes.

I am generating a group of check-boxes from a MySQL database with this code. $connection=mysql_connect ("localhost", "foo", "bar") or die ("I cannot connect to the database."); $db=mysql_select_db ("database", $connection) or die (mysql_error()); $query = "SELECT type FROM typelist ORDER BY type ASC"; $sql_result = mysql_query($query, ...

Running 100+ MySQL Update Queries. Optimization Tips Please :)

I'm working on this game titled "Fortress", located at http://www.joemajewski.com/fortress. Anyways, it's one of those browser-based role-playing games where players build an army and upgrade their stats to get a high ranking on the leaderboard. Every 30 minutes a cron job is going to execute, which makes some updates. It loops through ...

mysql: how to perform these 2 tasks

hi, how can I do the following points in mysql (possibly using phpmyadmin): 1) Given an existing column of numeric values (colA), create a new column with text data (colB) and automatically fill this column with "typeA" if colA = 0, and "typeB" if colB > 0 ? 2) Given the following 2 tables Users and Docs: Table Users has the columns ...