mysql

MySQL Optimization

Hello .. In my database of 5 million records .. Structure of the table: CREATE TABLE IF NOT EXISTS `music` ( `id` int(50) NOT NULL auto_increment, `artistname` varchar(50) NOT NULL, `songname` varchar(50) NOT NULL, `duration` varchar(6) NOT NULL, `url` varchar(255) NOT NULL, `server` int(5) NOT NULL, PRIMARY KEY (`id`), ...

MySQL - Fetch rows where a field value is less than 5 chars

I need to fetch all the rows where the 'zip' field is less than 5 characters. How can I achieve this using only SQL? I google'd first, but only found info on CHAR_LENGTH(). ie, psudeo code: SELECT * FROM users WHERE STRLEN(zip_code) < 5 Thanks! ...

PHP MYSQL to XML - Efficient File Generation

Hi there, I run a price comparison data engine, and as we are collecting so much data im running into pretty serious performance issues. We generate various XML files, one per product and within the product data is each Online shop we grab data from, with their price, link, description, etc. We have multiple feed parsers/scrapers which ...

What are secure approaches to handling a script that requires a database (MySQL) password?

Obviously, we don't want to hardcode the plaintext password in each script. This would make cycling the password difficult since a ton of scripts would need to be changed in addition to the password being in plaintext in the first place. If the scripts takes the password as a parameter, then we need to worry about modifying the 'ps' out...

Mysql - Valid Unique E-mail

I want to get the total number of all valid e-mail address in a database, but I also want the total to be unique e-mail addresses. Is this possible with mysql alone? ...

Database to GUI or Database to Object to GUI

I am making kind of CRUD application (Java GUI , MYSQL) Should I : load data from database to List (for example) and then List to GUI load data from database to Object(with attributes like SQL table) and Object to GUI Am I just paranoid or is another object really needed? ...

Limit the number of rows to join to, in mysql

So I want to join two tables together, but for each row in the first table, I only want to join it to the top 8 matching rows in the other table, ordered by one of the columns in that table. Any clever syntax I can use, or do I need to get messy with subqueries? ...

Computing Trending Topics

Let's say I'm collecting tweets from twitter based on a variety of criteria and storing these tweets in a local mysql database. I want to be able to computer trending topics, like twitter, that can be anywhere from 1-3 words in length. Is it possible to write a script to do something like this PHP and mysql? I've found answering on ho...

What is the syntax for a multi-table delete on a MySQL database using Doctrine?

Using Doctrine, I am trying to delete records in a single table based on data gathered from multiple tables. 'companies_groups' is an association table linking 'companies' to 'groups'. I want to delete all records in this table linked to a specific company, with the restriction that only 'companies_groups' records linked to a 'public' g...

mysql crash when calling show column for a View

Our mysql database sometimes crashes on a show column call for a View. The steps that i believe produce the problem are as follows. A view is being run at the same time that another user is logging into the mysql browser. The the database crashes: The following is what i found in the error file. We are using 5.0.45. Any ideas on steps...

Conditional filter for MySQL query

I've got a query that looks like this: select a.title, is.filename from articles a join article_images ai on ai.article_id = a.article_id join images i on i.image_id = ai.image_id join image_sizes is on is.image_id = i.image_id where is.size_name = '96x96'; So there is an N:N relationship between articles and images, and an N...

MySQL sort by average of two averages

I am working on a contest site where there are two types of users, normal site members, and judges. Each can use a drag and drop tool to order the entries in a particular contest in the order they choose. When they are done the relevant entry ids are attached a ranking value that can then be used to determine which entry in contest got t...

trying to use SOUNDEX in query but getting an error in terms of database columns in mysql...

Hi, Trying to figure out what went wrong, must be a silly syntax. $objDatabase = QApplication::$Database[1]; $strQuery = 'UPDATE `account` SET `sndx`=SOUNDEX("'.$objAccount->Name.'") WHERE `Id`='.$aid; $objDbResult = $objDatabase->Query($strQuery); The error I get is: MySqli Error: Unknown column 'sndx' in 'field list' Exception Typ...

Django MySql Raw Query Error - Parameter index out of range

This view is running fine on plain pyton/Django/mysql on Windows I'm porting this to run over jython/Django/mysql and it gives error - Exception received is : error setting index [10] [SQLCode: 0] Parameter index out of range (10 > number of parameters, which is 0). [SQLCode: 0], [SQLState: S1009] The Query is - cursor.execute(...

MySql: Operate on Many Rows Using Long List of Composite PKs

What's a good way to work with many rows in MySql, given that I have a long list of keys in a client application that is connecting with ODBC? Note: my experience is largely SQL Server, so I know a bit, just not MySQL specifically. The task is to delete some rows from 9 tables, but I might have upwards of 5,000 key pairs. I started ou...

Python error while using MysqlDb - sets module is deprecated

hi all, I'm currently getting the warning: /var/lib/python-support/python2.6/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated from sets import ImmutableSet everytime I run a python script that uses mysqldb. I'd rather not mess with their lib if possible. I'm on Ubuntu server. Anyone know an easy way to fix t...

unexpected mysql error saying must be an instance of mysqli_result?

Ugh, got this unexpected error: Argument 1 passed to QMySqliDatabaseResult::__construct() must be an instance of mysqli_result, boolean given, called in /home/aptana/domains/staging-allyforce.aptanacloud.com/web/htdocs/includes/qcodo/_core/database/QMySqli5Database.class.php on line 52 and defined Error Type: Unknown I'm not sure w...

Select ancestors and immediate children of a node in a nested set tree using MYSQL

Hoping some of you mysql experts can help me out. I have searchtag data that is stored in a nested set. TABLE searchTags searchTagID searchTag lft rgt (I am using nested sets because there are times when I need to easily select entire branches of the tree.) I would like to construct a query that will return a resultset of nodes ...

perl script to connect to mysql server port 3307

Hi, I am trying to connect to a mysql server which is running at port 3307. How do I connect to the server? I do not see any other way to specify port. I am using like this: #!/usr/bin/perl use Mysql; $host = "localhost"; $database = "abc"; $tablename = "def"; $user = "uuu"; $pw = "ppp"; $connect = Mysql->connect($host, $database, $...

Django MySQL full text search

I need to implement full text search for my Django application, running MySQL as backend. Let's say I've got a model as follows: class MyItem(models.Model): title = models.CharField() short_description = models.TextField() description = models.TextField() I would like to have results first for search term occurences in ti...