mysql

MySQL Replace characters in every table and column of a database

Hello I'd like to replace a string in every column and every table of a specific database. Is there a way to do this ? Thanks in advance :) Edit: That is because I have spotted Gibberish at some locations and it will take me days to fix it one by one ...

MySQL query to delete rows whose dates are close to another row

I've got a table containing many rows. The rows are guaranteed to have been inserted in order of a column called created_on, which is a datetime column. If a given row has a created_on time within 5 seconds of an existing row, I'd like to delete the given row. How would I write a query to delete those rows? ...

How to display a date as iso 8601 format with PHP

I'm trying to display a datetime from my MySQL database as an iso 8601 formated string with PHP but it's coming out wrong. 17 Oct 2008 is coming out as: 1969-12-31T18:33:28-06:00 which is clearly not correct (the year should be 2008 not 1969) This is the code I'm using: <?= date("c", $post[3]) ?> $post[3] is the datetime (CURRENT_TI...

General php function for multiple forms

I have a small application in which i have 9 different forms, and every form have a least 40+ fields where the user must enter some data. I have written each form in a single php file and made a master PHP file where i only add the form in the middle of the page. My question is: I don't want to write 9 different function for each form...

Log all requests to web site in database

I need to log all post and get requests on web site in the database. There will be two tables: requests with time stamp, user id and requested URI request parameters with name, value and request id I will use it only for analytical reports once per month. No regular usage of this data. I have about one million requests a day and th...

What are good Linux tool(s) for MySQL administration and profiling?

While Windows releases of MySQL administration and profiling tools seem to be a dime a dozen, I'm having a very hard time finding very many designed for Linux. Note that I'm not looking for monitoring software ala Nagios/Munin here. This would be something more along the lines of a SQLYog. While I could write some basic scripts to han...

How to import data to an in-memory database?

Are there any ways to import data in databases such as MS SQL, MySQL into in-memory databases like HSQLDB, H2 etc ? ...

Delphi 2009, MyDAC and relational database

Hello everyone! I have quite a problem concerning the use of relational database concepts in Delphi 2009 with MyDAC. I have a database structure that looks somehow like the following: Item id name Storage id name StorageItem id item_id storage_id place Now when I have an active dataset from "Item" how can I disp...

python-mysql : How to get interpolated query string?

In diagnosing SQL query problems, it would sometimes be useful to be able to see the query string after parameters are interpolated into it, using MySQLdb's safe interpolation. Is there a way to get that information from either a MySQL exception object or from the connection object itself? ...

Move Expired Items?

Hi guys, I have a model Post which has a expiry_date. I want to know what is the best way to manage scalability in this case. 2 options: Whenever I want to SELECT from the table, I need to include where expiry_date > NOW. If the table Post grows like a monster, I will be in trouble. Imagine after 3 years or more. Indexes will be huge ...

Equivalent C# / SQLite command for the PHP command mysql_insert_id()?

I'm used to using the command "mysql_insert_id()" in PHP to return the id of the last line inserted into my database. Is there an equivalent command in SQLite in C#? Thanks! -Adeena ...

using variable in mysql_fetch_assoc to output data from a column in a multi row.?

if i have a query like this $query = mysql_query(" SELECT * FROM tbl_school INNER JOIN tbl_livingexp ON (tbl_school.schoolname=tbl_livingexp.schoolname) INNER JOIN tbl_tuition ON (tbl_school.schoolname=tbl_tuition.schoolname) INNER JOIN tbl_apprequirments ON (tbl_school.schoolname=tbl_apprequirments.schoolname) where tbl_school.school...

mysql not updating from php form

I have a very simple PHP form, which shows a checkbox, and will store if it is checked or not in a database. This works for the initial inserting, but not for updating. I have tested cases where $saleid equals $pk and it does not enter the if branch to update...why? <?php error_reporting(E_ALL); if (isset($_GET["cmd"])) $cmd = $_GET[...

How do I sort into a dynamically generated specific order in mySQL?

I've been beating my brains in over this and I'm making no progress. I'm not very good with SQL so I'm hoping the answer is something simple that I just don't know. I have 2 tables: One called "images" that contains the data I want, organized with a primary key "imageID". The other is called "productPhotos", and it contains two fields (...

Whats a good advanced Mysql book to read?

Im looking to expand on the knowledge I already have. Whats a good book to do that? ...

Fast way to get the difference of 2 columns in MySQL

Hi, how do I get the fields of a column that's without a match in another column? I tried: SELECT table1.page_title FROM table1, table2 WHERE table1.page_title != table2.page_title It produces a lot of duplicate fields so I did a: SELECT DISTINCT table1.page_title FROM table1, table2 WHERE table1.page_title != table2.page_title ...

How to import SQL dump to a table without overwriting duplicate fields

Hi, how do I import a MySQL dump file to a database without overwriting records with the same value? ...

MySQL: Collect records from multiple queries into one result

I am looking to create a SQL query that collects the results from multiple queries. I would like to apply a random sort order and return a limited number of the records. The queries will all return the same field ("RefCode" in this example), but will have different FROM and WHERE statements. See an example below of some possible queri...

How do you create a form dropdown from a database table in php?

I am trying to code a function which creates a dropdown of school names selected from a database. It is doing fine creating a dropdown but it is not putting anything in the dropdown. Here is the code: function schoolDD($name, $selected){ $select = ''; if( $selected != null ) { $select = $selected; } $qry = "selec...

problems with update logic for a mysql db

I have the following PHP form, which posts back to a mysql database. My problem is that the update query seems to work, but is always overwritten with "checked". What I want to do is check is get the current value from the database, and then if there is a value in post, get that instead. Now...why is this not working? Do I need to have a...