mysql

Why is my SQL UPDATE statement not working in a loop?

The update statement in example is not working all the time even though the where clause is true. The database is MYSQL innodb. Would that cause some sort of locking ?? This is so weird. <?php $query = 'SELECT id FROM TABLE1'; $result = db_query($query); while($row = db_fetch_array($result)) { //do some process...

Setting multiple fields in a database, from just one field...

I am working in the confines of a CMS system, which defines certain fields which can be used to make forms for use within the application in PHP. I am making use of the inputSmartSearch field, which is basically similar to Google suggest. It allows me to define an SQL query, and then displays records that match as I type in my search. ...

using a mysql table to access a lookup table?

I have two tables. Lets say they look like this Table Sports: Column 1: id (integer) Column 2: name (varchar 100) Table Sport Articles: Column 1: id (integer) Column 2: data (text) Column 3: sport (integer) So what I want to do is select things from the sports articles. lets say I have the ID number already. all i want is the data an...

setuptools easyinstall mysql-python-1.2.3

Hi everybody I have read a bunch of threads on setuptools here. A lot of people seem not to like it very much. But I need to install MySQL-python-1.2.3. and when I do that I get this error: MySQL-python-1.2.3 X$ python setup.py cleanTraceback (most recent call last): File "setup.py", line 5, in <module> from setuptools ...

Update object instead of inserting with Doctrine using assignIdentifier()

I'm pretty new to Doctrine, but as I understand it, the assignIdentifier() method is supposed to tell Doctrine to update the relevant row into the database instead of inserting a new one. I have an object that I'm building through a workflow, so the identifier has an id of null until I call $object->save(); which inserts it, and this do...

multiple values in mysql variable

The following works as expected when there is a single value stored in a variable. SET @a := "20100630"; SELECT * FROM wordbase WHERE verified = @a; But it does not work when there are multiple values stored in a variable. SET @a := "'20100630', '20100701' "; SELECT * FROM wordbase WHERE verified in (@a); Do I need to use prepared...

How to implement select trim(string,','); for MySQL?

mysql> select trim(',hi,test,',','); ERROR 1064 (42000): You have an error in your SQL syntax; I want to trim by , but seems not supported by MySQL ...

Optimize an SQL query to get count of specific answers

I'm creating a survey with 10 questions. All questions have 5 possible answers with values from 1-5. The data is stored in a database with one row per user. There is a column for the answer to every question. To make bar graphs for the answers to every question, I currently retrieve the count of rows where the value of a specific colu...

PHP, MySQL, spatial data and design

Im building an application where vehicles coordinates are being logged by GPS. I want to implement a couple of features to start with, such as: realtime tracking of vehicles history tracking of vehicles keeping locations and area's for customer records I need some guidelines as where to start on database and application design. Anyth...

Comparing one table against another in MySQL

Guys, I have two basic tables (id, first_name). I want to run table 1 against table 2, delete duplicates, and spit out the cleansed version of table 1. What's the easiest way to do this with PHP/MySQL? Thanks. ...

How to show only date in DataColumn of Datatable?

Hi, I am populating one DataGridView in C# windows application. I have one DataTable in which I am displaying dates which I retrieve from database. My problem is, dates that I am getting from database includes time information also. For example, Jan 2003 12:00:00 AM ; I want to show only Jan 2003 part of that date in cells of datatable...

Using a single common WHERE condition for UNION in SQL

I am trying to do something like this: SELECT a.date AS EnrollDate, a.id, a.name, b.address FROM student a JOIN Location b ON a.id=b.id UNION SELECT a.date AS EnrollDate, a.id, a.name, b.address FROM teacher a JOIN Location b ON a.id=b.id WHERE a.date>'2010-01-01' ORDER BY EnrollDate But the WHERE condition applies to the se...

How to display all images when a link is clicked by using JQuery, PHP & MySQL?

I have this script that displays ten images or less by default but when a user clicks the <a> tag link it displays all the users images. Is there a way I can display all the users images by having them slide down when a user clicks on the link <a> link instead of refreshing the page using JQuery or PHP? Here is the php code. if(isset...

Mysql - can I have a View that is an in memory image of a table

I have a table with about 3000 records that I query often. Does mysql provide some sort of View that can load the table in memory and stay synced with my table (similar to a cache), so i can query this view and have really fast results? ...

Why my table is not using Index??

I cant see my table is using Index...EXPLAIN given me this id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE table1 const web web 258 const 1 1 SIMPLE table2 const web web 258 const 1 1 SIMPLE table3 const web web ...

interesting rails association challenge

I have stumbled on an interesting challenge regarding active record associations: I have an Account model which can have multiple and different organisations attached to it (like for example a Company, a Contractor, a Person) and it also has a different role with each association (accountant, owner, viewer, etc.). So I am not sure what...

What is the best way of uploading 1,600,000 rows of data into mysql database ?

This might sound dumb but yeah i need a effective way of doing this. Am using php at the moment and man it is slow. Any pointers please. Cheers. ...

Mmysql-python-1.2.3 install Mac OS 10.6

How can i install this? Any suggestion would be great. I have read these tutorials: http://www.tutorialspoint.com/python/python_database_access.htm http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/ http://openlandscape.wordpress.com/2007/11/16/setting-up-mysql-for-python-mysqldb-on-mac-os-x/ http://www.b...

How to select one text column, which string length >0 ?

Is there any function like "strlen" in mysql? ...

PHP flow logic problem

Hi guys, I have a bit of a problem with my PHP code, I am assigning values to variables in different states of the flow depending on what I receive, but for some reason it keeps getting stuck at one point, here is the code. if (isset($session)) { //if the user is in the database if ($row == 1) { $from = $_GET['from'];...