mysql

howto write email pattern in mysql?

What I've tried is as below: mysql> select '[email protected]' REGEXP '[a-zA-Z0-9_]+(?:[\-\+\.][a-zA-Z0-9_]+)*@[a-zA-Z0-9_]+(?:[\-\.\+][a-zA-Z0-9_]+)*\.[a-zA-Z0-9_]+(?:[\-\.\+][a-zA-Z0-9_]+)*'; ERROR 1139 (42000): Got error 'repetition-operator operand invalid' from regexp And I've no idea what's wrong with it. Can anyone here give me the rig...

mysql query browser edit button disabled

Has anyone had this problem? I deleted a column in the table editor and then went back to MySql Query Browser but the edit button was disabled. Can't seem to figure it out and I hate MySql's forum format so i decided to ask here. Any help is greatly appreciated! ...

Search inside Array for Value on a MYSQL Output

The code below doesn't seem to work or find anything on an array. I'm using "in_array" to search for the needle in the stack. I also tried exploding the contents with comma separated and won't work. Any suggestions? Also I tried "array_search". $q4 = "SELECT domain_name,slots_config.bid FROM slots_pid,slots_config,slots_sites WHERE slo...

counting the number of updates to a row in my mysql table

I have a simple mysql DB and use this PHP code to update it. mysql_query("REPLACE INTO `$db_table` (username, live, datetime, ip) VALUES ('$username', '1', '$timeofentry', '$ip')"); I use REPLACE INTO along with a primary key on "username" to let users bump themselves to the top of the most recent list... I would like to add a bump ...

Combining SQL Insert and Delete

Ok here is the question I have three tables events - id - name questions - id - event_id - name answers - id - question_id - description While generating the add form, i can simply search for all the questions belonging to particular event, and show the questions in single HTML form. But consider the edit scenario. An event manage...

How can I return records with a MySQL query using a regular expression?

I have records in my database that are searched with user input, and initially, this was sufficient for finding the correct records. "SELECT id FROM plants WHERE Flower LIKE '%" . $sanitizedUserInput . "%'" This was working all well and good, but then things started to happen like, searching 'red' was getting plants with the character...

MySQL backup and restore from command line.

Hi, I am using Command line to backup and restore MYSQL Database. Let use I m having a Database Data1 having Views and Procedures in it. When in Cmd line, I use mysql dump i.e ..>bin> mysqldump -u root -proot Data1> Datafile.mysql When I use above Cmd, It creates a Backup file on bin Folder of Mysql with Dtafile.mysql Name. but the ...

Select Something + An arbitrary Number in Mysql

I have a situation where I need to do something like select 2, id from users; I think that would work at least with Oracle but it doesn't work in Mysql. Any ideas? ...

MYSQL 8 Hours Time out Problem

I am using MYSQL 5.0 and Tomcat 5.5. After 8 hours , MYSQL closes by default closes all idle connections and so I am getting an SQL Exception .Any solution to this problem ...

Output of a query displaying as null

I am trying to trieve a list of files where a field ARTICLE_NO is a certain number. At the moment, I have a files table, with columns ARTICLE_NO, FILENAME and USERNAME. There is one record, with values 1, x.txt and user respectively. $pk is assigned to 1 in my php code. However, the following code only produces NULL, and I am unsure why....

convert mysql stored procedure to mssql

Hi, I need to used dynamic order query in mysql and i have successfully achieved that through string concatenation in mysql as follows: set @stmt_text := concat('select * from abc order by ',sorder); prepare stmt_handle from @stmt_text; execute stmt_handle; deallocate prepare stmt_handle; i need a similar way to convert this in mss...

mysql driver jar not being recognized

Hi all, I have an token class file in an jar file. The token class files is the class that uses jdbc to retrieve data from the database. However when I call the jar file it does not seem to recoginize the external mysql driver jar file. The error is pointed to this line Class.forName(driver);. I have referenced the mysql driver in...

Number of DB connections opened

Can anyone know the way to get the number of DB connection being used , in MYSQL 5.0 ...

Growing a list of links from a query

I have the following code, which will retrieve a filename from a table and make a link to it. What I want to do, is have it so I can refer to $filesList later on, and it will contain a single block of html code with links to as many files as there are files. I thought adding to the previous variable would be the easiest way to do this, ...

Can there be a database-agnostic SQL query to fetch top N rows?

We want to be able to select top N rows using a SQL Query. The target database could be Oracle or MySQL. Is there an elegant approach to this? (Needless to say, we're dealing with sorted data here.) ...

MySQL performance DELETE or UPDATE?

I have a MyISAM table with more than 10^7 rows. When adding data to it, I have to update ~10 rows at the end. Is it faster to delete them and then insert the new ones, or is it faster to update those rows? Data that should be updated is not part of the index. What about index/data fragmentation ...

How do you make the Python Msqldb module use ? in stead of %s for query parameters?

MySqlDb is a fantastic Python module -- but one part is incredibly annoying. Query parameters look like this cursor.execute("select * from Books where isbn=%s", (isbn,)) whereas everywhere else in the known universe (oracle, sqlserver, access, sybase...) they look like this cursor.execute("select * from Books where isbn=?", (isbn,)) ...

MySql Error 150 - Foreign keys

When I execute the follow two queries (I have stripped them down to absolutely necessary): mysql> CREATE TABLE foo(id INT PRIMARY KEY); Query OK, 0 rows affected (0.01 sec) mysql> CREATE TABLE bar ( id INT, ref INT, FOREIGN KEY (ref) REFERENCES foo(id)) ENGINE InnoDB; I get the following error: ERROR 1005 (HY000): Can't create ta...

Rails ActiveRecord - is there a way to perform operations on tables without an id?

I have a table with one row and two columns- int 'version', datetime 'updated' Is there a Rails ActiveRecord way to get and set the data in these columns? There is no id column. I'm using this table to track versions of queries of other tables. After each query of another table the version column is incremented and the updated colum...

How to automate migration (schema and data) for PHP/MySQL application

I have an application in PHP/MySQL. I am searching for an automated way upgrading database behind the application. I don't need to have the compatibility with older versions once it is upgraded. I have read jeff's and K. Scott Allen's articles on this. I am still not sure how to implement this for a PHP/MySQL application. Is there any...