mysql

Need a web host that allows MySQL triggers on shared accounts

Does anyone have experience with or know of a web host that allows the use of MySQL triggers on shared (read "cheap") accounts? I currently use Surpass Hosting and they told me this was a feature they won't support for security reasons. Update I've checked with bluehost, Host Monster, and DreamHost and none of them support triggers. ...

Can you define "literal" tables in SQL?

Is there any SQL subquery syntax that lets you define, literally, a temporary table? For example, something like SELECT MAX(count) AS max, COUNT(*) AS count FROM ( (1 AS id, 7 AS count), (2, 6), (3, 13), (4, 12), (5, 9) ) AS mytable INNER JOIN someothertable ON someothertable.id=mytable.id This would sav...

How to use the LIKE statement correctly in a MySql SELECT statement?

Why isn't this working? DELIMITER ;// CREATE PROCEDURE `blah` ( SearchText varchar(4000) ) BEGIN SELECT * FROM table_name WHERE table_name.StringField LIKE '%' + SearchText + '%'; -- This is where the code is breaking END;// ...

On field UPDATE if value is already SET, SET it to something else?

I know I can easily do this with a few lines of PHP but I was hoping there was a method in MYSQL to do this; I would think there is but I am not having any luck finding it. Basically I want to do this: UPDATE fieldName SET status='1' if status='1', SET status='2' So that second line is obviously not real code, but that is what I want...

POST variable problem.

I'm having a really strange problem with this code I'm working on at the moment. It's a map editor for a game that sends the variables for each tile to another PHP file to update the mySQL database. So far the map editor code displays the map and loads everything fine. The map update (mupdate) PHP file correctly updates the database, if...

mysql concat() to create column names?

I would like to concatenate column names in a way that the first part of the column name is a string and the second part is a number which is the result of another query. For example: SELECT CONCAT('column', mytable.mycolumn) FROM table ... Can this be done in some way. This way it doesn't give me errors but I don't get the expected ...

mysql 12 hr to 24 hr time conversion

How can we convert the time in AM/PM to 24-hrs format. For eg. (1:30 PM) should be converted to (13:30). ...

JPA native query for LONGTEXT field in a MySQL view results in error

Hi, I have the following JPA SqlResultSetMapping: @SqlResultSetMappings({ @SqlResultSetMapping(name="GroupParticipantDTO", columns={ @ColumnResult(name="gpId"), @ColumnResult(name="gpRole"), // @ColumnResult(name="gpRemarks") } ) Which is used like this: StringBuilder sbQuer...

Mysql Query

Hi, I want to fetch all the records in one line with First Name LastName , First Name Last Name, etc........ in mysql Query. For example, mytable looks like this: rec Id First Name Last Name 1 Gnaniyar Zubair 2 Frankyn Albert 3 John Mathew 4 Suhail Ahme...

how to get accurate or (near accurate) distance between two places? Mysql/PHP

Hi SELECT postcode, lat, lng, truncate( (degrees(acos (sin(radians(`lat`)) * sin( radians('.$latitude.')) + cos(radians(`lat`)) * cos( radians('.$latitude.')) * cos( radians(`lng` - ('.$longitude.'))) ) ) * 69.172), 2) as distance FROM `myData` This query calculates distance (in m...

how to set up a php mysql site quickly?

Hello, I am looking for ways to setup a basic site quickly. I have a basic site which works with a databasem, templates, css, js and so on. No I want to be able to quickly set up a site. What shoudld happen when i start the script is: ask for some variables on submit: create a folder in the webroot copy the standard site to that map ...

Encoding problems in Linux & MySQL

I have developed my Java/EE program in Windows machine and everything worked perfectly in Windows, but when I installed my WAR to Jboss in Linux machine I have encoding issues with MySQL when I import csv-files. Csv files are encoded as ISO-8859-1 and file I import is encoded as ISO-8859-1. MySQL doesn't seem to get Strings encoded as UT...

mysql java cant execute stored procedure

I am connecting to a mysql(5.08) db running on a linux machine from a web application running in tomcat. I get the following exception..when I try to execute a stored procedure.. com.hp.hpl.chaos.web.exception.DBException: getNextValue for operatorinstance[Additional Information from SQL Exception][SQLErrorCode: 0 SQLState: S1000 a...

What would cause my MySQL query to hang after two results?

Hi, I have a simple query that I can't for the life of my get to print out on my page: $results = mysql_query("SELECT * FROM andyasks ORDER BY date"); $test = mysql_fetch_array($results, MYSQL_BOTH); foreach ($test as $row){ print($row[questions]); } What this outputs is (unpredictably, to my eyes) just the first letter of each ta...

How to do a regular expression replace in MySQL?

I have a table with ~500k rows; varchar(255) UTF8 column filename contains a file name; I'm trying to strip out various strange characters out of the filename - thought I'd use a character class: [^a-zA-Z0-9()_ .\-] Now, is there a function in MySQL that lets you replace through a regular expression? I'm looking for a similar functiona...

Wordpress database backup

does anyone know of a good way to automatically backup databases used for wordpress blogs? Preferably a way of getting the backup emailed as a .zip file to the admin user so they can be stored remotely? ...

Unique Constraint with conditions in MYSQL

In postgres we have a constraint defined that essentially allows us to limit the number of entries in a table with a certain value to one. We created this constraint: create unique index list$default$uk on list_group(visitor_uid) where list_type = 'default'; Which means that the unique constraint is only applied when the list_type='de...

Referencing the next iteration before it happens in PHP

Hi, I have a table in MySQL with "text", "date_posted", and "user". I currently query all text from user=Andy, and call those questions. All of the other text fields from other users are answers to the most recent question. What I want is to associate those answers with the most recent question, with a loop similar to "for each text wh...

Why does MySQL CONVERT_TZ alter the seconds after timezone adjustment?

I'm storing UTC datetime values in MySQL. I use CONVERT_TZ to handle timezone conversion to query/save local datetimes to/from UTC in the database. Upon testing I noticed this strange peculiarity in how the conversion works. Can anyone explain why it is MySQL is adding 23 seconds when using the -4:00 hour offset, but not when using th...

Spawn and detach PHP process without sharing any db-resources so that the child can exit?

I want an "eternal" process that goes through a MySQL table and spawns child processes. Pseudo code: while(true) $rows = SELECT * FROM workers foreach($rows as $row){ DELETE $row->id spawn_child($row->id) } sleep(5) } function spawn_child($id){ $pid = pcntl_fork() if($pid <0){ //err ...