mysql

MySQL multi table queries

Hi community. I have a bunch of data ordered by date and each table holds only one month of data. (The reason for this is to cut down query time, I'm talking about millions of rows in each month table) For ex. data_01_2010 holds data from 2010-01-01 to 2010-01-31 data_02_2010 holds data from 2010-02-01 to 2010-02-28 Sometimes I hav...

MySQL query. Cannot do WHERE on alias... alternative??

I want to do the following query: SELECT getDistance(lat1, lng1, lat2, lng2) as `distance`, `forename`, `surname`, `etc..` WHERE `distance` < 10 ORDER BY `distance` ASC Obviously it won't work because you cannot do WHERE clauses on column 'alias'... can anyone help with an alternative?? getDistance() is a custom procedure... this ret...

html form not sending correct data, php pagination

I have recently used a php pagination tutorial http://www.tonymarston.net/php-mysql/pagination.html to display record information from mysql database. The problem is that the page only sends out the information sent in the latest form and am not quite sure how to fix the problem. the code for the form output is shown below $musicitems...

Does anyone know of a good framework or application to rapidly build front-ends for MySQL and PHP based web applications?

Can anyone recommend a good, visually attractive PHP framework or application to rapidly create back office / admin interfaces to MySQL based applications. I generally have to build bespoke back office UIs for every PHP web based application I write and wondered if there is an easier way of quickly building a web front-end to MySQL data...

Mysql Slave not updating

I have replication set up every thing looks fine I have not errors , but the data is not being moved to the Slave mysql> show slave status \G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: xxxxx Master_User: xxxxxx ...

PHP PDO Related: Update SQL Statement not Updating the content of Database

I am trying to implement update statement using prepared statement in php script but it appears that it is not update record in the database and am not sure why and so would appreciate if you can share some insights. Code $query = "UPDATE DatTable SET DF_PARTY_ID = :party_id, DF_PARTY_CODE = :party_code, DF_CONNECT...

Accent-insensitive sorting in MySQL

I am trying to achieve accent and case-insensitive sorting in MySQL. Following the instructions in the manual, this is supposed to work with the utf8 character set and utf8_general_ci collation. When I follow the example in the manual (http://dev.mysql.com/doc/refman/5.1/en/charset-collation-implementations.html) under "Collations for ...

How to get current snapshot of MySQL Database Table and FTP it to remote server using PHP.

Here is the scenario: I get an CSV file, which has data1, data2, data3, data4(Add, Update, Delete), data5 and there are like 90000 entries in the CSV file, first line gives description of column like DATE AGE NAME STATUS(ADD, UPDATE, DELETE) TIME 1 01/02 23 Phil A 23:00:00 2 02/03 32 ...

How do I upload new data-base structure into mysql from my development db?

Hi, we've been making changes in the mysql database, adding tables, columns and so forth and I have a development/staging site and production. All are MySQL, staging and production hosted remote. How do I export the table structure and bring it into the production environment? I have been using myphpadmin to administer it to date. Th...

Compare structures of two databases?

Hello, I wanted to ask whether it is possible to compare the complete database structure of two huge databases. We have two databases, the one is a development database, the other a production database. I've sometimes forgotten to make changes in to the production database, before we released some parts of our code, which results that t...

Count the sum of a column values in a SELECT statement

Hi, I have a table where I should count if an user has reached a number of penalities like 3, so if the user reach or surpass 3 points, he's banned: table_warnings - id - user_id - warning - warning_date id user_id warning warning_date 1 5478 1 2010-02-25 12:59:00 2 5478 1 2010-02-28 08...

How to update sql query with jquery

Hello, I am still trying to update my sql query more dynamically but finding it difficult since im new to both PHP and jquery. I have one main page (pagination.php) that looks like this: <?php function generate_pagination($sql) { include_once('config.php'); $per_page = 3; //Calculating no of pages $result = mysql_query($sql)...

Managing cross database reading, views or permissions in MySql

I will have multiple tables used by different projects on the same mySql server. Much of the data is sensitive, and needs to be behind permissions wall. However many of the tables of sensitive data rely on tables of insensitive data for user and department information. So I see three options ahead of me and I am unsure which one to pi...

PSP class import + MySQL connect

Ok so im trying to import a class i made which connects to a MySQL database the class code is shown below: class connection def__init__( self ): self.cnx = MySQLdb.connect(user='xxx',host='xxx',passwd='xxx',db='xxx') All of the parameters for the mysql connection are correct and file containg the class is in the same direc...

select from another mysql host

hi is it possible to execute a SELECT command on a mysql host db2, being logined to mysql host db1? e.g. i'm logined on mysql server db1, and i want to SELECT some data from db1 tables and db2 server tables with one query. i've found out that i can use FEDERATED tables, but i'm looking for a simpler way, if it exists ...

Do multiple mysqli_queries use the same connection?

I have a mysqli_query statement like so: $result = mysqli_query($connection,$query) I am wondering: If I call mysqli_query multiple times during the execution of a script, does it use the same connection to the db? Or is a new connection established each time? Thanks, ...

mysql: Duplicate entry '0' for key 'PRIMARY' and bizarre ID behavior

See log below. (Snipped just for brevity; unsnipped @ http://pastebin.com/k9sCM6Ee) In short: somehow rows are getting assigned ID 0. When this happens, it blocks inserts, even when those inserts aren't actually conflicting with ID 0 (although that really shouldn't happen in the first place). Although it is heavily read and very heavil...

Is there some kind of "strict performance mode" for MySQL?

I'd like to setup one instance of MySQL to flat-out reject certain types of queries. For instance, any JOINs not using an index should just fail and die and show up on the application stack trace, instead of running slow and showing up on the slow_query_log with no easy way to tie it back to the actual test case that caused it. Also, I'...

How to import selected fields in mysql

For example I have a table. With a field Idnumber. And the field has 10 data(ex: 1234, 1235, 1236, etc) And I have another table, subjects. Is it possible to import the data that is in the table student(field idnumber) and put it on the table subjects(field idnumber)? So that I won't have to copy and paste the data that is in the source ...

Why doesn't MySQL define a boolean data type?

MySQL doesn't define a distinct boolean data type, opting instead to make BOOL and BOOLEAN aliases for TINYINT(1). Why is this so? ...