mysql

How to group data in PHP inside the while loop

I query in a database and loop the result using while and heres the sample data retrieve: echo $db->f("FirstName")."===".$db->f("Question")."=".$db->f("Answer")."<br>"; Michael===Q2=allergy Michael===Q2=Hives Michael===Q6=A lot Michael===Q8_A=Daktacort Michael===Q1=Itch Michael===Q5=Smoke Michael===Q8_A=Diprogenta Christian===Q1=Stuffy...

MySQL locking question

I have something similar to an online chat client. When one user sends a message it will be stored in a MySQL database table with id=currentID+1. I have another client long polling and waiting for message 'id=currentID+1'. After this exchange, that row is never used again. Do I need a lock in this case? The thing I'm worried about is t...

How can I tell what the value of a mysql variable is during the execution of a stored procedure

I am having a problem where a stored procedure is taking a long time. We have two variables created @start_date and @end_date from other queries earlier in the script. Is there a way to see what those values are during the execution of the script? The script takes 3 hours to complete when it really shouldn't, I suspect the dates are off...

MySqlConnection really not close

Hi guys, i've a huge problem. Take a look to this sample code private sub FUNCTION1() dim conn as new mysqlconnection(myconnstring) conn.open ---- do something FUNCTION2() ---- conn.close end sub private sub FUNCTION2() dim conn as new mysqlconnection(myconnstring) .... conn.open ...

quickest way of deleting data from mysql

i am doing this: delete from calibration_2009 where rowid in (SELECT rowid FROM `qcvalues`.`batchinfo_2009` where reporttime like "%2010%"); i need to have about 250k rows deleted. why does it take such a long time? is there a quicker way to do this? ...

Can php listen for a mysql database change or update? ...thinking real-time, live search here

Im trying to think of the best way to handle real time search for a website. The only solution I can come up with is to keep checking the server every few seconds for something new in the database, but that does not seem very practical to me. ...

Updating fields in one table that are not empty

I got this SQL: UPDATE users2 SET picture = 'sites/site2/files/pictures/' + picture; WHERE picture NOT IS NULL And the only thing I get are that all picture fields get the value '0'. ...

Best Approach for Checking and Inserting Records

EDIT: To clarify the records originally come from a flat-file database and is not in the MySQL database. In one of our existing C programs which purpose is to take data from the flat-file and insert them (based on criteria) into the MySQL table: Open connection to MySQL DB for record in all_record_of_my_flat_file: if record contain a...

What db fits me?

Dear Everyone I am currently using mysql. I am finding that my schema is getting incredibly complicated. I seek to find a new db that will suit my needs: Let's assume I am building a news aggregrator (which collects news from multiple website). I then run algorithms to determine if two news from different sites are actually referring to...

MYSQL Select statment Order By with Group By

I have the following simple SQL statment SELECT id, name, value_name, value_id FROM table GROUP BY id ORDER BY value_id DESC when grouping I would like to get the value_name and value_id of the tuple where the value_id is the biggest. The way it is i am getting the smallest value. For example 1, name1, valuename, 3 (where i know ...

does mysql undo changes if you kill thread?

i ran a delete rows query. it was taking too long so i killed the thread from administration. did it undo the changes to the table/? ...

delete records from a table based on data from a different table

table1 has column CITY and COUNTRY. table2 has column CITY. how do i delete from table2 all records that have CITY in common with table1 but also the COUNTRY='Russia' ?? please keep in mind that both tables have about 1 million rows of data ...

Recommended approach for error handling with PHP and MYSQL

I am trying to capture database (MYSQL) errors in my PHP web application. Currently, I see that there are functions like mysqli_error(), mysqli_errno() for capturing the last occurred error. However, this still requires me to check for error occurrence using repeated if/else statements in my php code. You may check my code below to see w...

MySQL: Data query from multiple tables with views

I want to create a query result page for a simple search, and i don't know , should i use views in my db, would it be better if i would write a query into my code with the same syntax like i would create my view. What is the better solution for merging 7 tables, when i want to build a search module for my site witch has lots of users an...

Problem creating a database with PHP PDO

Hello guys, I'm having a problem with a SQL query in my PHP Application. When the user access it for the first time, the app executes this query to create all the database: CREATE TABLE `databases` ( `id` bigint(20) NOT NULL auto_increment, `driver` varchar(45) NOT NULL, `server` text NOT NULL, `user` text NOT NULL, `password...

estimating how long a delete statement should take in mysql

DELETE table2 FROM table2 INNER JOIN table1 ON table2.CITY = table1.CITY WHERE table1.COUNTRY = 'Russia' both tables have about half a million records, about 10 columns each. each column is not larger than about 100 characters how long will this take if there are about 250,000 records matching the criteria? ...

jQuery and MySQL

I have taken a jQuery script which would remove divs on a click, but I want to implement deleting records of a MySQL database. In the delete.php: <?php $photo_id = $_POST['id']; $sql = "DELETE FROM photos WHERE id = '" . $photo_id . "'"; $result = mysql_query($sql) or die(mysql_error()); ?> The jQuery script: $(document).ready...

PHP/MySQL won't update decimal field

I have this query: UPDATE table_name SET field_1 = field_1 +100, field_2 = field_2 +100, field_3 = field_3 +100 WHERE id = 1 LIMIT 1; Where Field_1 is regular integer, Field_2 is decimal(15,6) and Field_3 is double(15,6). When I run this query from php script they update just field_1 and nothing happen with field_2 an...

delete taking really long time! mysql

i am doing this: delete calibration_2009 from calibration_2009 join batchinfo_2009 on calibration_2009.rowid = batchinfo_2009.rowid where batchinfo_2009.reporttime like '%2010%'; both tables have about 500k lines of data i suspect that 250k match the criteria to be deleted so far it has been running for 2 hours!!! is there something ...

MySQL: what is a temporary table?

What is the purpose of a temporary table like in the following statement? How is it different than a regular table? CREATE TEMPORARY TABLE tmptable SELECT A.* FROM batchinfo_2009 AS A, calibration_2009 AS B WHERE A.reporttime LIKE '%2010%' AND A.rowid = B.rowid; ...