mysql

MySQL Subquery Causing Server to Hang

I'm trying to execute the following query SELECT * FROM person WHERE id IN ( SELECT user_id FROM participation WHERE activity_id = '1' AND application_id = '1' ) The outer query returns about 4000 responses whilst the inner returns 29. When executed on my web server nothing ha...

Mysql connection with python in a class

i'm trying to connect to a database building a class connection()saved in local folder in file utils.py .This is what i worked so far of it: class connection: def __init__(self): self.conn = MySQLdb.connect(host = "localhost",user = "xxx", passwd = "xxx", db = "xxx", ...

How should I go about modeling event duration

Env: mysql How should I go about modeling the event duration for the following scenarios... Today is Monday (start of the week) One day event scheduled between 10 AM - 5 PM today. Every day event open from 10 AM - 11 AM from today till 1 week. (inclusive of weekends) Every day event open from 10 AM - 11 AM from today till 2 weeks. (e...

Interacting with a Database from Scheme

Hi, i try to learn scheme and as a test project i wanted to create a very simple website with 1-2 database queries (MySQL preferred, but PostgreSQL would be ok, too). I know it's not really schemes domain but i still want to see how far i can come. Sadly, it seems i'm already stuck at using a database and googling for "scheme database" ...

MySQL performance, inner join, how to avoid Using temporary and filesort

Hi, I have a table 1 and table 2. Table 1 PARTNUM - ID_BRAND partnum is the primary key id_brand is "indexed" Table 2 ID_BRAND - BRAND_NAME id_brand is the primary key brand_name is "indexed" The table 1 contains 1 million of records and the table 2 contains 1.000 records. I'm trying to optimize some query using EXPLAIN and after a l...

Figuring SQL QUERY for EACH ISSET ?

Hello guys I'm stucked in a point and I need your help. I want to change SQL QUERY for each $_GET parameters. I'm using this: <? if (isset($_GET['page']) ) { $pageno = $_GET['page']; } else { $pageno = 1; } // if $query = mysql_query("SELECT count(id) FROM m3_music_mp3"); $query_data = mysql_fetch_row($query); $numrows = $query_da...

What is wrong with my index on this MySQL query?

select xml_record_product.product_id, IfNull(xml_record_product.product_short_description,xml_record_product.product_description) AS BookDescription, xml_record_product.product_image, xml_record_product.product_publisher_name AS Publisher, xml_record_prod...

How to check if a MySQL connection is closed in Python?

The question says everything. How can I check if my MySQL connection is closed in Python? I'm using MySQLdb, see http://mysql-python.sourceforge.net/ ...

Can sql multi query be considered an atomic instruction?

Hi all, For the php implementation point of view, is the multi_query an atomic instruction on the data base or all it does is executing all queries sequentially? Thanks. ...

No duplicate rows, but redundant data

I have a mySQL table which represents a company's products. The table shows whether or not two products are compatible with each other. The table looks somewhat like Product1 Product2 Compatible? A A Yes A B ? A C No A D ? B A ? B ...

how to insert excel data in a database with java

hi, i want to insert data from an excel file into a local database in a UNIX server with java without any manipulation of data. 1- someone told me that i've to convert the excel file extension into .csv to conform with unix. i created a CSV file for each sheet (i've 12) with a macro. the problem is it changed the date format from DD-...

How to change URL's for each ISSET with PAGINATION?

I'm using this script to pagination. But when url does have $_GET['word'] I cant change URL's of Links. How can I do it? <? if (isset($_GET['page']) ) { $pageno = $_GET['page']; } else { $pageno = 1; } // if $limit = ""; if(isset($_GET['word'])) { $word = mysql_real_escape_string($_GET['word']); $word = $word{0}; $limit = "...

MAC OSX MySQL Query Log not writing

I have my my.cnf with this setting [mysqld] general_log =1 general_log_file = /var/log/mysqld.log query_cache_type=1 query_cache_size=64M also had it before set to [mysqld] log = /var/log/mysqld.log query_cache_type=1 query_cache_size=64M I know I had this working at one point but when I went to go tail it today I noticed it wasn...

MYSql query to concanate all the values in each row based on the comman same id matching.

Is there any way to concatenate the value in a field that matching with a comman field say userid. For eg if this is the table, UserID| Field1  |  Field2 1        | aaa    |   zzz 1        | bbb    |   yyy 1        | ccc    |   xxx i want it as a single row like-- UserID | Field1  |  Field2 1        | aaa,bbb,ccc,    |   zzz,yyy,x...

how to save an users vote on a comment to mysql via php?

How to save an users vote on a particular comment? For example if someone likes a comment posted on the site he/she will click the (+) button or other way will click the (-) button. How could i save this information to mysql, so that when the user come back to the site I can show his/her vote on the comment? Something like facebook comme...

How do you decide between what you put in your config file and your database

Does anyone have a good system for deciding what to put in the database and what to put in the config file. My config file is a php array and I have a mysql database. If for example I have a data set of 5 'rows' that will rarely change (if ever) is it better to keep it in the config file? I am looking for a rule that I can follow that...

Using AJAX for an auto-updating page containing values from a database?

Hello. Can someone explain how to create a .php page which auto-updates with values from a database? Would using AJAX be best for something like this? I want this PHP code, but I want the page to be updated whenever 'values01' is added to or changed, without having to refresh the page. $query = "SELECT values01 FROM users WHERE username...

a bash script to dump a database

how to write a bash script which will dump a database and restore it. there should be two arguments. first one is the name of db which is going to be dumped and another one is name of the db in which i am going to restore the previously dump data. ...

mysql query add [something]_ infront of all table rows when grabbing multiple tables

Example of what I want to do: select a.* as a_, b. as b_* FROM a, b WHERE a.id = b.id ...

Return perl array to MATLAB

Is there a way to return a perl array to MATLAB? Or do I just have to return a string and parse it? I'm using a call from MATLAB to a perl script to interface with a MySQL database. After I get the results of a query, I want to pass it back to MATLAB. EDIT: I'm using a modified version of perl.m to call the perl script. It calls the ver...