mysql

Tomcat does not recognize the MySQL .jar library

I tried several different ways such that Tomcat loads the MySQL drivers when running my web application. I'm using Ubuntu 8.04, and the libraries come from the libmysql-java package. They are located in the directory shown below: ~$ ls /usr/share/java/mysql* /usr/share/java/mysql-connector-java-5.1.5.jar My CLASSPATH includes this fi...

Any way to speed up this query?

This query is really slow. Takes between 9 and 10 seconds... SELECT DISTINCT a.* FROM addresses a LEFT JOIN contacts c ON c.id = a.contact_id LEFT JOIN organizations o ON o.id = a.organization_id ORDER BY c.last_name, c.first_name, o.name LIMIT 0, 24 If I comment out the ORDER BY clause the query runs much faster -- about 5 millisecon...

what's the best way to represent a many-to-many relationship in a database?

If I have a number of users and a number of pages, and each user can administrate any number of the pages, and each page can be administrated by any number of the administrators, how could I store all of these permissions in a database? For example, I could have a field in the users table, which is just a comma-delimited list of page ID...

php/timeout/connection to server reset?

I have a php script that needs to run for quite some time. What the script does: connects to mysql initiates anywhere from 100 to 100,000 cURL requests each cURL request returns compact-decoded data of 1 to 2000 real estate listings - i use preg-match-all to get all the data and do one mysql insert per listing. each query never exceed...

How can I do a contiguous group by in MySQL?

How can I return what would effectively be a "contiguous" GROUP BY in MySQL. In other words a GROUP BY that respects the order of the recordset? For example, SELECT MIN(col1), col2, COUNT(*) FROM table GROUP BY col2 ORDER BY col1 from the following table where col1 is a unique ordered index: 1 a 2 a 3 b 4 b 5 a 6 a ...

How to partition Mysql across MULTIPLE SERVERS?

I know that horizontal partitioning...you can create many tables. How can you do this with multiple servers? This will allow Mysql to scale. Create X tables on X servers? Does anyone care to explain, or have a good beginner's tutorial (step-by-step) that teaches you how to partition across multiple servers? ...

How to import csv files selected by user to database

Hi I wonder how i can import csv files that selected by user to database using php. is there any practical way on this ? thanks ...

php mail() statments

Hello i am trying to get all the users infomation from the database and check the timestamp (fourteendays) and check it with the time now i got the time bit working but i can''t get it to send to all the when the time is > fourteendays $result1 = mysql_query("SELECT * FROM accounts") or die (mysql_error()); while ($row1 = mysql_fet...

Database Error Handling: What if You have to Call Outside service and the Transaction Fails?

We all know that we can always wrap our database call in transaction ( with or without a proper ORM), in a form like this: $con = Propel::getConnection(EventPeer::DATABASE_NAME); try { $con->begin(); // do your update, save, delete or whatever here. $con->commit(); } catch (PropelException $e) { $con->rollback(); thr...

Cakephp Pagination Sort data out of model

I currently have a query that results in the following recordset: Array ( [Contestant] => Array ( [id] => 1 [name] => test [age] => [city] => atest [telephone] => [email] => [email protected] [why_model_house] => a [highschool] => [photo] => 5329_119145013633_512383633_2487923_7196193_n0.jpg [active] => 1 ) [0] => Array ( [Contestant_votes...

How to order by maximum of two column which can be null in MySQL?

create table jobs( id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, ..... salaryminus INTEGER UNSIGNED DEFAULT NULL, salaryplus INTEGER UNSIGNED DEFAULT NULL, ..... ); I want to do something like : Select * from jobs order by maxof(salaryminus, salaryplus) limit 10; maxof(Null,1000) should be 1000, H...

Why does MySQL insert 3 values instead of 1?

Hey guys, I am having trouble with what seems to be fairly easy. Let me tell you what I'm trying to do, and then I will paste in my commented code. I am trying to: Connect to MySQL Insert an incrementing value (the id) Temporarily store that value [i used mysql_insert_id()] Upload and resize an image using the class.upload.php and giv...

Empty records are inserted at each load of the web page

I am having a registration page. when the page is loaded, everytime it tries to insert the values in the textboxes which is empty by default at first. Please help. My code is attached register.template.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html ...

Mysql Group By Problem ?

Can someone help me with the this? This is my table structure: rec_id product_id quantity quantity_in quantity_out balance stock_date status 1 2 342 NULL 17 325 2009-10-23 1 2 2 325 NULL 124 201 2009-10-23 1 3 1 ...

On a 20 gig disk, I have a mysql folder of 17gig, but I have 16 gig free?

Hello, I am wondering how this is possible. At my host, I have a Mysql folder that is 17 Gig big, however I have only 20Gig, but DF and the admin panel say's I still have 16Gig Free. How is this possible? Does anyone know? Thank you ...

a MYSQL script to convert the column names to lowercase

I am looking for a single MYSQL script to convert ALL column names in a database to lowercase in one go... I have inherited a MYSQL database that has a lot of mixed case column names (150 tables with a strange naming convention) and I don't want to go through manually each table by table to do this. Has anyone got such a script? Thank...

What kind of queries a website like stackoverflow use?

Hi, I am learning mysql join queries. To pratice, I decided to make tables for a website like stackoverflow. I made three tables basically. Question_Thread thread_id title username datetime Question_Reply reply_id thread_id text Question_Text_Comment comment_id reply_id comment How do I q...

Use of wildcards in mysql table name

The table names in my mysql database are dynamically generated. Is there some way to select data from tables which have a name matching a pattern? I guess it will look like: select * from 'table_id_%' ...

Tricky query solution

Hello everyone, Does anyone have any idea on how can you create a product filtering query (or queries) that will emulate the results on this page? http://www.emag.ro/notebook%5Flaptop Explanation If you press HP as a brand, the page will show you all the HP products, and the rest of the available filters are gathered from this query ...

MySQL: get multiple-keyed rows matching several WHERE conditions (probably simple)

I have a table of userdata that includes user ID and category IDs. I want to grab all of the users that are associated with multiple category IDs, eg: id | UserID | CategoryID 1 | 123456 | 999 2 | 123456 | 888 3 | 123457 | 999 4 | 123458 | 777 So for example, if I wanted to get all users with a categoryID of 999, I'd get 123456 and...